N
Nuxt4mo ago
drusellers

Find Client Side calls preventing server render

From the docs
When importing a library that relies on browser APIs and has side effects, make sure the component importing it is only called client-side. Bundlers do not treeshake imports of modules containing side effects.
How can I best find these browser apis? Can I make nuxt throw an error on build - looking for a similar error experience as Next.js has with their client side vs server side components.
5 Replies
Smef
Smef4mo ago
If you have a component that can only operate client-side, you can name the component MyComponent.client.vue and it won't be rendered on the server
drusellers
drusellers4mo ago
word - will it throw an error if it tries to do server side stuff? is the opposite true can I have a .server.vue that will error on access to things like window?
drusellers
drusellers4mo ago
hopefully - https://roe.dev/blog/nuxt-server-components - is still relevant
A guide to Nuxt server components
It's possible to use server components within Nuxt, even if you are generating a static site. Here's how.
From An unknown user
From An unknown user
Smef
Smef4mo ago
Yes, that's correct .server is server-only, and the non-interactive result would be sent as HTML
Smef
Smef4mo ago
Want results from more Discord servers?
Add your server