This section outlines the breaking changes introduced since version 4 of Astro Typesafe Routes. Review the details below to ensure a smooth upgrade.
Support for Astro ^4.0.0
has been dropped. Please upgrade to ^5.0.0
to stay compatible.
Getting typed params now use createRoute
and Route.getParams
instead.
const { id } = getParams(Astro, "/[id]");
Replace with:
const Route = createRoute({
routeId: "/blog/[id]",
});
const { id } = Route.getParams(Astro);
The search schema is now declared inside createRoute
.
export const searchSchema = z.object({ limit: z.number() });
Replace with:
export const Route = createRoute({
routeId: "/",
searchSchema: z.object({ limit: z.number() }),
});
Typed search params are now accessed from Route.getSearch
.
const search = getSearch(Astro, searchSchema);
Replace with:
const search = Route.getSearch(Astro);
The type Route
has been renamed to RouteId
.
import { Route } from "astro-typesafe-routes/path";
Replace with:
import { RouteId } from "astro-typesafe-routes/path";
Spread params are now passed without the ...
prefix.
<Link to="/blog/[...path]" params={{ "...path": "about" }}>
Blog
</Link>
Replace with:
<Link to="/blog/[...path]" params={{ path: "about" }}>
Blog
</Link>