Skip to content

Commit 414fba4

Browse files
Sync kit docs (sveltejs#1070)
sync kit docs Co-authored-by: Rich-Harris <[email protected]>
1 parent 3afb347 commit 414fba4

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

apps/svelte.dev/content/docs/kit/20-core-concepts/40-page-options.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ By default, SvelteKit will render (or [prerender](glossary#Prerendering)) any co
77

88
You can control each of these on a page-by-page basis by exporting options from [`+page.js`](routing#page-page.js) or [`+page.server.js`](routing#page-page.server.js), or for groups of pages using a shared [`+layout.js`](routing#layout-layout.js) or [`+layout.server.js`](routing#layout-layout.server.js). To define an option for the whole app, export it from the root layout. Child layouts and pages override values set in parent layouts, so — for example — you can enable prerendering for your entire app then disable it for pages that need to be dynamically rendered.
99

10-
You can mix and match these options in different areas of your app. For example you could prerender your marketing page for maximum speed, server-render your dynamic pages for SEO and accessibility and turn your admin section into an SPA by rendering it on the client only. This makes SvelteKit very versatile.
10+
You can mix and match these options in different areas of your app. For example, you could prerender your marketing page for maximum speed, server-render your dynamic pages for SEO and accessibility and turn your admin section into an SPA by rendering it on the client only. This makes SvelteKit very versatile.
1111

1212
## prerender
1313

@@ -128,6 +128,8 @@ export const ssr = false;
128128

129129
If you add `export const ssr = false` to your root `+layout.js`, your entire app will only be rendered on the client — which essentially means you turn your app into an SPA.
130130

131+
> [!NOTE] Even with `ssr` set to `false`, code that relies on browser APIs should be imported in your `+page.svelte` or `+layout.svelte` file instead. This is because page options can be overriden and need to be evaluated by importing your `+page.js` or `+layout.js` file on the server (if you have a runtime) or at build time (in case of prerendering).
132+
131133
## csr
132134

133135
Ordinarily, SvelteKit [hydrates](glossary#Hydration) your server-rendered HTML into an interactive client-side-rendered (CSR) page. Some pages don't require JavaScript at all — many blog posts and 'about' pages fall into this category. In these cases you can disable CSR:

apps/svelte.dev/content/docs/kit/40-best-practices/07-images.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ CDNs can generally be used without any need for a library. However, there are a
159159
- Consider serving all images via CDN regardless of the image optimization types you use. CDNs reduce latency by distributing copies of static assets globally.
160160
- Your original images should have a good quality/resolution and should have 2x the width it will be displayed at to serve HiDPI devices. Image processing can size images down to save bandwidth when serving smaller screens, but it would be a waste of bandwidth to invent pixels to size images up.
161161
- For images which are much larger than the width of a mobile device (roughly 400px), such as a hero image taking the width of the page design, specify `sizes` so that smaller images can be served on smaller devices.
162-
- For important images, such as the [largest contentful paint (LCP)](https://web.dev/articles/lcp) image, set `fetchpriority="high" loading="eager"` to prioritize loading as early as possible.
162+
- For important images, such as the [largest contentful paint (LCP)](https://web.dev/articles/lcp) image, set `fetchpriority="high"` and avoid `loading="lazy"` to prioritize loading as early as possible.
163163
- Give the image a container or styling so that it is constrained and does not jump around while the page is loading affecting your [cumulative layout shift (CLS)](https://web.dev/articles/cls). `width` and `height` help the browser to reserve space while the image is still loading, so `@sveltejs/enhanced-img` will add a `width` and `height` for you.
164164
- Always provide a good `alt` text. The Svelte compiler will warn you if you don't do this.
165165
- Do not use `em` or `rem` in `sizes` and change the default size of these measures. When used in `sizes` or `@media` queries, `em` and `rem` are both defined to mean the user's default `font-size`. For a `sizes` declaration like `sizes="(min-width: 768px) min(100vw, 108rem), 64rem"`, the actual `em` or `rem` that controls how the image is laid out on the page can be different if changed by CSS. For example, do not do something like `html { font-size: 62.5%; }` as the slot reserved by the browser preloader will now end up being larger than the actual slot of the CSS object model once it has been created.

apps/svelte.dev/content/docs/kit/98-reference/20-$app-navigation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424

2525
## afterNavigate
2626

27-
A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a new URL.
27+
A lifecycle function that runs the supplied `callback` when the current component mounts, and also whenever we navigate to a URL.
2828

2929
`afterNavigate` must be called during a component initialization. It remains active as long as the component is mounted.
3030

apps/svelte.dev/content/docs/kit/98-reference/20-$app-state.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ NOTE: do not edit this file, it is generated in apps/svelte.dev/scripts/sync-doc
33
title: $app/state
44
---
55

6-
SvelteKit makes three readonly state objects available via the `$app/state` module — `page`, `navigating` and `updated`.
6+
SvelteKit makes three read-only state objects available via the `$app/state` module — `page`, `navigating` and `updated`.
77

88
> [!NOTE]
99
> This module was added in 2.12. If you're using an earlier version of SvelteKit, use [`$app/stores`]($app-stores) instead.
@@ -17,7 +17,7 @@ import { navigating, page, updated } from '$app/state';
1717

1818
## navigating
1919

20-
An object representing an in-progress navigation, with `from`, `to`, `type` and (if `type === 'popstate'`) `delta` properties.
20+
A read-only object representing an in-progress navigation, with `from`, `to`, `type` and (if `type === 'popstate'`) `delta` properties.
2121
Values are `null` when no navigation is occurring, or during server rendering.
2222

2323
<div class="ts-block">
@@ -41,7 +41,7 @@ const navigating:
4141

4242
## page
4343

44-
A reactive object with information about the current page, serving several use cases:
44+
A read-only reactive object with information about the current page, serving several use cases:
4545
- retrieving the combined `data` of all pages/layouts anywhere in your component tree (also see [loading data](/docs/kit/load))
4646
- retrieving the current value of the `form` prop anywhere in your component tree (also see [form actions](/docs/kit/form-actions))
4747
- retrieving the page state that was set through `goto`, `pushState` or `replaceState` (also see [goto](/docs/kit/$app-navigation#goto) and [shallow routing](/docs/kit/shallow-routing))
@@ -76,7 +76,7 @@ const page: import('@sveltejs/kit').Page;
7676

7777
## updated
7878

79-
A reactive value that's initially `false`. If [`version.pollInterval`](/docs/kit/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update `current` to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling.
79+
A read-only reactive value that's initially `false`. If [`version.pollInterval`](/docs/kit/configuration#version) is a non-zero value, SvelteKit will poll for new versions of the app and update `current` to `true` when it detects one. `updated.check()` will force an immediate check, regardless of polling.
8080

8181
<div class="ts-block">
8282

0 commit comments

Comments
 (0)