Guest-01
Guest-01

Reputation: 823

does using nuxt with `ssr: false` makes nuxt same as regular vue with nodejs hosting?

if you set ssr: false in nuxt.config.js file, does this make nuxt work exactly same as plain Vue application?

if so, doing npm run build, npm run start will just serve static html/css/js file with node.js server?

Am I right here?

Upvotes: 0

Views: 1164

Answers (2)

kissu
kissu

Reputation: 46602

Yeah, that will make Nuxt behave like Vue for the rendering part.
Be sure to have generate for an SSG target and not build (for SSR).

Here are more details of the benefits of still using Nuxt: https://stackoverflow.com/a/74714106/8816585


If you're doing npm run build, it's supposing that you're using your Nuxt app as SSR. Which means pretty much nothing since you don't want SSR (false).

It's like saying

I want a tomato sandwich, but without the tomato.

In the current situation, Nuxt3 will probably give you a sandwich but without tomatoes aka SPA-only Nuxt3 generated as SSG. Totally hostable as any other regular SPA app, on Netlify.

Official source: https://nuxt.com/docs/getting-started/deployment#client-side-only-rendering


Also, what Nuxt is doing during local development and on production are 2 different things.
You will always have a Node.js server running for dev, but that is not the case once deployed (SSG, SPA, etc...).
If you want a Nuxt3 SSR'ed app, use build + ssr: true.

Upvotes: 1

nur_riyad
nur_riyad

Reputation: 1370

From the nuxt3 document

ssr - Disables server-side rendering for sections of your app and make them SPA-only with ssr: false

What I understand from the doc

When SSR is false and use npm run build

If you make ssr: false and build the project not generate, then It will work like a simple vue spa application. Like a traditional spa application, it will load the whole js in the initial load and then render in the client site.

When SSR is false and use npm run generate

Again if you make ssr: false and generate the project not build, Then it will prerender all the pages and generate the static file. And it will work like a traditional static website. But you have to be careful that as SSR is false it will not prefetch any data it needs in the generated time. So It's best to generate pages with SSR mode on.

Upvotes: 1

Related Questions