App router without server? Is it possible?
Answered
Black Caiman posted this in #help-forum
Black CaimanOP
I understand that, by default, all components inside
app are Server Components, and that they can be turned into Client Components by specifying use client at the top. But does this still mean that a server is required to use the App router, even if all of my components/pages have use client? Or could I still for example use Next.js in "SPA-mode" with output: "export" alongside the App router?4 Replies
@Black Caiman I understand that, by default, all components inside `app` are Server Components, and that they can be turned into Client Components by specifying `use client` at the top. But does this still mean that a server is **required** to use the App router, even if all of my components/pages have `use client`? Or could I still for example use Next.js in "SPA-mode" with `output: "export"` alongside the App router?
with output export, you don't need a running server yes
Answer
that, of course, requires you to make all pages static (so all server components can be built at build time)
Black CaimanOP
Gotcha, thanks. I'm trying to use Next.js in a way that I have the option to add SSR later down the line, but prefer running it as an SPA until I am ready to get into SSR. Seems like that is still possible then without having to use the old (soon deprecated?) Pages Router. Thanks!
@Black Caiman Gotcha, thanks. I'm trying to use Next.js in a way that I have the option to add SSR later down the line, but prefer running it as an SPA until I am ready to get into SSR. Seems like that is still possible then without having to use the old (soon deprecated?) Pages Router. Thanks!
don't worry the pages router is not gonna be deprecated soon. you can use any, or both of them, if you like. but yes you understand it very well