Skip to content

Releases: tatethurston/nextjs-routes

v0.1.0

27 Sep 23:09
9171055
Compare
Choose a tag to compare

0.1.0

This release contains a breaking change, indicated by the minor version bump to 0.1.0. nextjs-routes has not yet reached v1, but will follow semantic versioning once it does. Until then, minor version changes will be used to help flag breaking changes.

  • Breaking change: the withRoutes import path and invocation has changed to better align with the general pattern in the Nextjs plugin ecosystem and to support configuration options, notably the new outDir option. It also now includes an ESM export to support usage in next.config.mjs.
- const { withRoutes } = require("nextjs-routes/next-config.cjs");
+ const withRoutes = require("nextjs-routes/config")();

/** @type {import('next').NextConfig} */
const nextConfig = {
 reactStrictMode: true,
};

module.exports = withRoutes(nextConfig);

Note the import path has changed and the import itself has changed to function that is invoked with any configuration options. This provides better ergonomics for configuration options:

const withRoutes = require("nextjs-routes/config")({ outDir: "types" });
  • The type RoutedQuery has been added to retrieve the Query for a given Route. This is useful as the context type parameter inside getStaticProps and getServerSideProps. Thanks @MariaSolOs for the contribution!

  • withRoutes now accepts outDir as a configuration option to dictate where nextjs-routes.d.ts is generated. Thanks @MariaSolOs for the contribution!

New Contributors

Full Changelog: v0.0.22...v0.1.0

v0.0.22

23 Sep 19:58
6781d0d
Compare
Choose a tag to compare

0.0.22

  • Deprecate direct invocation of nextjs-routes in favor of automatic regeneration via withRoutes. See #63 for the motivation behind this change or to voice any concerns.

Full Changelog: v0.0.21...v0.0.22

v0.0.21

17 Aug 23:44
fe907a2
Compare
Choose a tag to compare

What's Changed

  • Add route runtime for generating type safe paths from a Route object

This can be used to fetch from API routes:

import { route } from "nextjs-routes";

fetch(route({ pathname: "/api/foos/[foo]", query: { foo: "foobar" } }));

Or for type safe redirects from getServerSideProps:

import { route } from "nextjs-routes";

export const getServerSideProps: GetServerSideProps = async (context) => {
  return {
    redirect: {
      destination: route({ pathname: "/foos/[foo]", query: { foo: "foobar" } }),
      permanent: false,
    },
  };
};

Full Changelog: v0.0.20...v0.0.21

v0.0.20

08 Aug 22:59
2cb52d0
Compare
Choose a tag to compare

What's Changed

  • Move chokidar from devDependencies to dependencies so it's installed automatically.

Full Changelog: v0.0.19...v0.0.20

v0.0.19

08 Aug 17:17
f724a77
Compare
Choose a tag to compare

What's Changed

  • Bug Fix: quote query segments in generated types. See #49 for more context. Thanks @OliverDudgeon for reporting.
  • Bug Fix: don't generate routes for non navigable routes (_error, _app, _document). Thanks @JohnDaly for reporting.
  • Bug Fix: don't generate routes for test files that are co-located in pages directory. See #50 for more context. Thanks @JohnDaly for reporting.

Full Changelog: v0.0.18...v0.0.19

v0.0.18

13 Jul 23:13
83f52d2
Compare
Choose a tag to compare

What's Changed

  • query is now typed as string | string[] | undefined instead of string | undefined by @sachinraja.

  • nextjs-routes can now be configured via your next.config.js to automatically regenerate types whenever your routes change:

    // next.config.js
    
    /** @type {import('next').NextConfig} */
    const { withRoutes } = require("nextjs-routes/next-config.cjs");
    
    const nextConfig = {
      reactStrictMode: true,
    };
    
    module.exports = withRoutes(nextConfig);

    This wiring will only run in Next.js' development server (eg npx next dev) and withRoutes will no-op in production.

Full Changelog: v0.0.17...v0.0.18

v0.0.17

08 Jul 23:45
d2f2db1
Compare
Choose a tag to compare

What's Changed

  • re-export types from next/link and next/router by @sachinraja.
  • remove prettier as a peer dependency by @sachinraja.
  • enable src/pages for windows users.
  • routes are now generated for routes that start with _. _app, _document, _error and middleware are excluded.
  • gracefully handles missing pages directory and no pages.

Full Changelog: v0.0.16...v0.0.17

v0.0.16

08 Jul 17:34
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.0.15...v0.0.16

v0.0.15

07 Jul 21:20
7bf7868
Compare
Choose a tag to compare

What's Changed

  • nextjs-routes no longer adds types to the global type namespace. Previously,
    Route was available globally. Now, it must be imported:
import type { Route } from "nextjs-routes";
  • query from useRouter is now correctly typed as string | undefined instead of string. If you know the current route, you can supply a type argument to narrow required parameters to string, eg:
  // if you have a page /foos/[foo].ts

  const router = useRouter<"/foos/[foo]">();
  // foo will be typed as a string, because the foo query parameter is required and thus will always be present.
  const { foo } = router.query;

Full Changelog: v0.0.14...v0.0.15

v0.0.14

07 Jul 02:57
b618e60
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.0.13...v0.0.14