Pages Router
Pages Router in the Next.js to ShadowJS guide.
| Pages Router | Dusk |
|---|---|
pages/index.tsx, pages/posts/[id].tsx |
routes/index.tsx, routes/posts/[id].tsx |
pages/_app.tsx |
src/app.tsx (the root component), providers go here |
pages/_document.tsx |
The document shell Dusk writes; document: { lang, head } in the handler options |
getServerSideProps |
A route loader calling a server function. It also runs in the browser on client navigations |
getStaticProps |
A loader plus export const prerender = true: the build renders the page to a file |
getStaticPaths |
export const prerender = ["/posts/1", "/posts/2"], or prerender: { routes: [...] } in dusk(); the list is a literal or computed in vite.config.ts. Use a route’s revalidate for ISR; Next’s fallback: "blocking" is not an option |
pages/api/** |
routes/api/** as above |
useRouter().query |
useParams() and useSearch() |
next/head |
A route's head |
next/dynamic |
lazy from @shadow-js/web |
next/router events |
useNavigation(), useBeforeLeave, useBlocker (from @shadow-js/router/blockers) |