Skip to main content
Basic Svelte
Introduction
Reactivity
Props
Logic
Events
Bindings
Classes and styles
Actions
Transitions
Advanced Svelte
Advanced reactivity
Reusing content
Motion
Advanced bindings
Advanced transitions
Context API
Special elements
<script module>
Next steps
Basic SvelteKit
Introduction
Routing
Loading data
Headers and cookies
Shared modules
Forms
API routes
Stores
Errors and redirects
Advanced SvelteKit
Hooks
Page options
Link options
Advanced routing
Advanced loading
Environment variables
Conclusion

Server-side rendering (SSR) is the process of generating HTML on the server, and is what SvelteKit does by default. It’s important for performance and resilience, and is very beneficial for search engine optimization (SEO) — while some search engines can index content that is rendered in the browser with JavaScript, it happens less frequently and reliably.

That said, some components can’t be rendered on the server, perhaps because they expect to be able to access browser globals like window immediately. If you can, you should change those components so that they can render on the server, but if you can’t then you can disable SSR:

src/routes/+page.server
export const ssr = false;

Setting ssr to false inside your root +layout.server.js effectively turns your entire app into a single-page app (SPA).

Edit this page on GitHub

previous next
1
2
<h1>{window.innerWidth}x{window.innerHeight}</h1>