v0.0.21
What's Changed
- Add
route
runtime for generating type safe paths from aRoute
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