Skip to content

Commit

Permalink
[docs] adapter-static: document prerender.default and info about disa…
Browse files Browse the repository at this point in the history
…bling 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 <322311+benmccann@users.noreply.github.com>

* make the example config syntactically valid

* shuffle things around

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Rich Harris <hello@rich-harris.dev>
  • Loading branch information
3 people authored Mar 14, 2022
1 parent 9d726f1 commit 87c89d7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/adapter-static/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ export default {
assets: 'build',
fallback: null,
precompress: false
})
}),

prerender: {
// This can be false if you're using a fallback (i.e. SPA mode)
default: true
}
}
};
```

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.

> ⚠️ 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.
## Options
Expand Down Expand Up @@ -66,7 +69,9 @@ export default {
};
```

When operating in SPA mode, only pages that have the [`prerender`](https://kit.svelte.dev/docs/page-options#prerender) option set will be prerendered.
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.

> ⚠️ 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).
## GitHub Pages

Expand Down

0 comments on commit 87c89d7

Please sign in to comment.