Releases: tatethurston/nextjs-routes
v2.0.1
2.0.1
-
Fix
GetServerSidePropsContext
andGetServerSidePropsResult
types. Thanks @po4tion! -
Change generated file location from
nextjs-routes.d.ts
to@types/nextjs-routes.d.ts
. Thanks @po4tion!To preserve the old location, make the following change to your
next.config.js
:const nextRoutes = require("nextjs-routes/config"); const withRoutes = nextRoutes({ + outDir: "", });
Otherwise, delete your old
nextjs-routes.d.ts
once@types/nextjs-routes.d.ts
is generated.
New Contributors
Full Changelog: v2.0.0...v2.0.1
v2.0.0
What's Changed
- Route type generation can now also be generated outside of
next build
/next dev
by usingnpx nextjs-routes
. router.query
types must now be narrowed usingrouter.isReady
. This ensures types are correct for pages that use Automatic Static Optimization.
Next's documentation notes the following:
During prerendering, the router's query object will be empty since we do not have query information to provide during this phase. After hydration, Next.js will trigger an update to your application to provide the route parameters in the query object.
See #117 for more context and discussion.
import { useRouter } from "next/router";
const router = useRouter<"/foos/[foo]">();
// query is now typed as `{ foo?: string | undefined }`. Previously this was `{ foo: string }` which was not safe for static optimized pages
router.query;
Updating useRouter
call sites to check isReady
will narrow the query type:
import { useRouter } from "next/router";
const router = useRouter<"/foos/[foo]">();
// query is now typed as `{ foo?: string | undefined }`. Previously this was `{ foo: string }` which was not safe for static optimized pages
router.query;
+ if (router.isReady) {
+ // query is typed as `{ foo: string }`
+ router.query;
+ }
Full Changelog: v1.0.9...v2.0.0
v1.0.9
What's Changed
- Enable
Link
androuter
methods to only update the routehash
. Thanks @sitch! - Publish commonjs for
route
runtime so jest tests don't require transpilation for users. Thanks @panudetjt! - Add
GetServerSideProps
andGetServerSidePropsContext
types. Thanks @slhck!
Full Changelog: v1.0.8...v1.0.9
v1.0.8
v1.0.7
1.0.7
- Remove package.json version import. This resolves
TypeError[ERR_IMPORT_ASSERTION_TYPE_MISSING]
. See #115 for more context.
Full Changelog: v1.0.6...v1.0.7
v1.0.6
v1.0.5
What's Changed
- The version of
nextjs-routes
is now included in the generatednextjs-routes.d.ts
file. - Switch
Link
to use TypeScript unions instead of function overloading. Function overloading resulted in errors that were difficult for users to understand, and created issues for some use cases.
Full Changelog: v1.0.4...v1.0.5
v1.0.4
1.0.4
-
LinkProps
now accept path strings for static routes:import { LinkProps } from "next/link"; // previously this would error const props: LinkProps = { href: "/foo" };
Full Changelog: v1.0.3...v1.0.4
v1.0.3
1.0.3
-
The
Route
type now includeshash
. This enables the following:// this will link to /foo#bar <Link href={{ pathname: "/foo", hash: "bar" }}>Foo</Link>
Full Changelog: v1.0.2...v1.0.3
v1.0.2
1.0.2
-
Link
now accepts anchor props:<Link href="/dashboard" className="border-indigo-500"> Dashboard </Link>
Full Changelog: v1.0.1...v1.0.2