From fe907a295c788d3193309e5918aec3197640794f Mon Sep 17 00:00:00 2001 From: Tate Thurston Date: Wed, 17 Aug 2022 16:43:17 -0700 Subject: [PATCH] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c66d13b..99c3983 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ This wiring will only run in Next.js' development server (eg `npx next dev`) and ## What if I need a runtime? -There are some cases where you may want to generate a type safe pathname from a `Route` object, such as `fetch`ing from an API route or serving type safe redirects from `getServerSideProps`. These accept `strings` instead of the `Route` object that `Link` and `useRouter` accept. This requires a small amount of runtime code instead of a type only solution. +There are some cases where you may want to generate a type safe path from a `Route` object, such as when `fetch`ing from an API route or serving redirects from `getServerSideProps`. These accept `strings` instead of the `Route` object that `Link` and `useRouter` accept. Because these do not perform the same string interpolation for dynamic routes, runtime code is required instead of a type only solution. For these cases, you can use `route` from `nextjs-routes`: @@ -173,8 +173,8 @@ export const getServerSideProps: GetServerSideProps = async (context) => { return { redirect: { destination: route({ pathname: "/foos/[foo]", query: { foo: "foobar" } }), - permanent: false, - }, + permanent: false + } }; }; ```