Skip to content

Releases: tatethurston/nextjs-routes

v2.2.0

27 May 19:15
49e3ae3
Compare
Choose a tag to compare

What's Changed

  • Add trailingSlash option to route. See #168
  • Fix the generated optional catch all route type. See #183
  • Sort the generated route types lexicographically.

Full Changelog: v2.1.0...v2.2.0

v2.1.0

04 Nov 18:40
fdc0255
Compare
Choose a tag to compare

What's Changed

Full Changelog: v2.0.1...v2.1.0

v2.0.1

14 May 19:33
231d0f3
Compare
Choose a tag to compare

2.0.1

  • Fix GetServerSidePropsContext and GetServerSidePropsResult 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

09 Apr 18:40
cfb9dfe
Compare
Choose a tag to compare

What's Changed

  • Route type generation can now also be generated outside of next build / next dev by using npx nextjs-routes.
  • router.query types must now be narrowed using router.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

31 Mar 22:02
fdabd49
Compare
Choose a tag to compare

What's Changed

  • Enable Link and router methods to only update the route hash. Thanks @sitch!
  • Publish commonjs for route runtime so jest tests don't require transpilation for users. Thanks @panudetjt!
  • Add GetServerSideProps and GetServerSidePropsContext types. Thanks @slhck!

Full Changelog: v1.0.8...v1.0.9

v1.0.8

20 Jan 19:57
a0b1f35
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.0.7...v1.0.8

v1.0.7

05 Jan 22:03
76ec23f
Compare
Choose a tag to compare

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

04 Jan 11:18
2fa480c
Compare
Choose a tag to compare

What's Changed

  • Fix bad publish of 1.0.5 (missing runtime)

Full Changelog: v1.0.5...v1.0.6

v1.0.5

04 Jan 10:33
c3734c4
Compare
Choose a tag to compare

What's Changed

  • The version of nextjs-routes is now included in the generated nextjs-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

22 Nov 20:01
bc0fdc9
Compare
Choose a tag to compare

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