Skip to content

Commit 87c89d7

Browse files
Theo-SteinerbenmccannRich-Harris
authored
[docs] adapter-static: document prerender.default and info about disabling ssr in dev (#4304)
* [docs] document new prerender.default setting * [docs] add explanation about dev / production discrepancy * Remove trailing comma * Fix weird code description * Run prettier * Wording Co-authored-by: Ben McCann <[email protected]> * make the example config syntactically valid * shuffle things around Co-authored-by: Ben McCann <[email protected]> Co-authored-by: Rich Harris <[email protected]>
1 parent 9d726f1 commit 87c89d7

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/adapter-static/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ export default {
1818
assets: 'build',
1919
fallback: null,
2020
precompress: false
21-
})
21+
}),
22+
23+
prerender: {
24+
// This can be false if you're using a fallback (i.e. SPA mode)
25+
default: true
26+
}
2227
}
2328
};
2429
```
2530

26-
Unless you're in [SPA mode](#spa-mode), the adapter will attempt to prerender every page of your app, regardless of whether the [`prerender`](https://kit.svelte.dev/docs/page-options#prerender) option is set.
27-
2831
> ⚠️ You must ensure SvelteKit's [`trailingSlash`](https://kit.svelte.dev/docs/configuration#trailingslash) option is set appropriately for your environment. If your host does not render `/a.html` upon receiving a request for `/a` then you will need to set `trailingSlash: 'always'` to create `/a/index.html` instead.
2932
3033
## Options
@@ -66,7 +69,9 @@ export default {
6669
};
6770
```
6871

69-
When operating in SPA mode, only pages that have the [`prerender`](https://kit.svelte.dev/docs/page-options#prerender) option set will be prerendered.
72+
When operating in SPA mode, you can omit `config.kit.prerender.default` (or set it to `false`, its default value), and only pages that have the [`prerender`](https://kit.svelte.dev/docs/page-options#prerender) option set will be prerendered at build time.
73+
74+
> ⚠️ During development, SvelteKit will still attempt to server-side render your routes. This means accessing things that are only available in the browser (such as the `window` object) will result in errors, even though this would be valid in the output app. To align the behavior of SvelteKit's dev mode with your SPA, you can [call `resolve()` with a parameter of `{ssr: false}` inside the `handle()` hook](https://kit.svelte.dev/docs/hooks#handle).
7075
7176
## GitHub Pages
7277

0 commit comments

Comments
 (0)