Skip to content

v0.0.21

Compare
Choose a tag to compare
@tatethurston tatethurston released this 17 Aug 23:44
· 107 commits to main since this release
fe907a2

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