Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting Server Side Rendering in Nuxt.js

I have a Nuxt.js app that uses Server Side Rendering. However in one of my pages I need to detect if it's SSR for a toggle of one of the components. What are some possible ways of creating an isSSR flag?

like image 480
Stromwerk Avatar asked May 21 '20 09:05

Stromwerk


People also ask

Is Nuxt server-side rendering?

Nuxt. js is a framework for Vue. js applications that can solve this problem with server-side rendering, a strategy that renders the application on the server then sends it to the client. With Nuxt, all of your routes are generated from .

Is Nuxt server-side or client-side?

Both the browser and server can interpret JavaScript code to render Vue. js components into HTML elements. This step is called rendering. Nuxt supports both client-side and universal rendering.

What server does Nuxt use?

Nuxt 3 is powered by a new server engine, Nitro. Cross-platform support for Node.


1 Answers

Use just

process.server

Vue exposes two attributes on process global variable. server and client and one of them is set true according to rendering side.

like image 114
farincz Avatar answered Sep 30 '22 14:09

farincz