nextjs-routes
Advanced tools
Changelog
2.2.4
route
's handling of query keys whose value is undefined
. Fixes #206. Thanks @sleepdotexe!Changelog
2.2.3
usePathname
and useParams
were incorrectly resolving to any
return types.Changelog
2.2.2
Adds support for Next.js's app
directory. Link
accepts either static routes (no url parameters) or a RouteLiteral
string, which can be generated by the route
helper from this library:
import { route } from "nextjs-routes";
<Link
href={route({
pathname: "/foos/[foo]",
query: { foo: "bar" },
})}
>
Baz
</Link>;
Add RouteLiteral
type. This type represents a string that has been confirmed to be a validated application route and can be passed to Link
or useRouter
. This is a TypeScript branded type.
import { RouteLiteral } from "nextjs-routes";
route
returns a RouteLiteral
. If you construct a route string you can cast it to a RouteLiteral
so that Link
and useRouter
will accept it:
const myRoute = `/foos/${foo}` as RouteLiteral
In general, prefer using the route
helper to generate routes.
Refine types for usePathname
, useRouter
and useParams
from "next/navigation"
to use nextjs-routes
generated types.
Fix generated routes when using parallel-routes and intercepting-routes.
Fix ref
type for Link
. Previously ref
was missing, now it's correctly typed.