Skip to content

Commit 27c8538

Browse files
authored
Merge branch 'main' into fix-highlighting
2 parents 353c798 + 793236f commit 27c8538

28 files changed

+1075
-1181
lines changed

.github/workflows/docs-preview-create.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ on:
1919
description: 'Branch (eg. my-feature-branch)'
2020
required: true
2121
type: string
22+
check_id:
23+
description: 'The ID of the check that triggered this workflow'
24+
required: false
25+
type: string
2226

2327
permissions:
2428
contents: write
@@ -62,7 +66,7 @@ jobs:
6266
6367
- name: Push
6468
id: push
65-
run: git add -A && git commit -m "sync docs" && git push -u origin ${{ env.BRANCH }} --force
69+
run: git add -A && git commit -m "sync docs for check run ${{ inputs.check_id }}" && git push -u origin ${{ env.BRANCH }} --force
6670

6771
- name: Request preview comment
6872
uses: peter-evans/repository-dispatch@v3

apps/svelte.dev/.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
content/docs
22
scripts/create-tutorial-zip/common/.svelte-kit
33
land-110m.json
4+
src/lib/tutorial/adapters/common/unzip.cjs

apps/svelte.dev/content/docs/kit/20-core-concepts/20-load.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ Universal `load` functions are called with a `LoadEvent`, which has a `data` pro
207207

208208
A universal `load` function can return an object containing any values, including things like custom classes and component constructors.
209209

210-
A server `load` function must return data that can be serialized with [devalue](https://github.com/rich-harris/devalue) — anything that can be represented as JSON plus things like `BigInt`, `Date`, `Map`, `Set` and `RegExp`, or repeated/cyclical references — so that it can be transported over the network. Your data can include [promises](#Streaming-with-promises), in which case it will be streamed to browsers. If you need to serialize/deserialize custom types, use [transport hooks](https://svelte.dev/docs/kit/hooks#Universal-hooks-transport).
210+
A server `load` function must return data that can be serialized with [devalue](https://github.com/rich-harris/devalue) — anything that can be represented as JSON plus things like `BigInt`, `Date`, `Map`, `Set` and `RegExp`, or repeated/cyclical references — so that it can be transported over the network. Your data can include [promises](#Streaming-with-promises), in which case it will be streamed to browsers. If you need to serialize/deserialize custom types, use [transport hooks](hooks#Universal-hooks-transport).
211211

212212
### When to use which
213213

apps/svelte.dev/content/docs/kit/20-core-concepts/60-remote-functions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ The override will be applied immediately, and released when the submission compl
419419

420420
By default, submitting a form will send a request to the URL indicated by the `<form>` element's [`action`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/form#attributes_for_form_submission) attribute, which in the case of a remote function is a property on the form object generated by SvelteKit.
421421

422-
It's possible for a `<button>` inside the `<form>` to send the request to a _different_ URL, using the [`formaction`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#formaction) attribute. For example, you might have a single form that allows you to login or register depending on which button was clicked.
422+
It's possible for a `<button>` inside the `<form>` to send the request to a _different_ URL, using the [`formaction`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#formaction) attribute. For example, you might have a single form that allows you to log in or register depending on which button was clicked.
423423

424424
This attribute exists on the `buttonProps` property of a form object:
425425

@@ -453,7 +453,7 @@ The `command` function, like `form`, allows you to write data to the server. Unl
453453
454454
> [!NOTE] Prefer `form` where possible, since it gracefully degrades if JavaScript is disabled or fails to load.
455455
456-
As with `query`, if the function accepts an argument it should be [validated](#query-Query-arguments) by passing a [Standard Schema](https://standardschema.dev) as the first argument to `command`.
456+
As with `query`, if the function accepts an argument, it should be [validated](#query-Query-arguments) by passing a [Standard Schema](https://standardschema.dev) as the first argument to `command`.
457457
458458
```ts
459459
/// file: likes.remote.js
@@ -728,7 +728,7 @@ export const getStuff = query('unchecked', async ({ id }: { id: string }) => {
728728
729729
## Using `getRequestEvent`
730730
731-
Inside `query`, `form` and `command` you can use [`getRequestEvent`](https://svelte.dev/docs/kit/$app-server#getRequestEvent) to get the current [`RequestEvent`](@sveltejs-kit#RequestEvent) object. This makes it easy to build abstractions for interacting with cookies, for example:
731+
Inside `query`, `form` and `command` you can use [`getRequestEvent`]($app-server#getRequestEvent) to get the current [`RequestEvent`](@sveltejs-kit#RequestEvent) object. This makes it easy to build abstractions for interacting with cookies, for example:
732732
733733
```ts
734734
/// file: user.remote.ts
@@ -757,4 +757,4 @@ Note that some properties of `RequestEvent` are different inside remote function
757757
758758
## Redirects
759759
760-
Inside `query`, `form` and `prerender` functions it is possible to use the [`redirect(...)`](https://svelte.dev/docs/kit/@sveltejs-kit#redirect) function. It is *not* possible inside `command` functions, as you should avoid redirecting here. (If you absolutely have to, you can return a `{ redirect: location }` object and deal with it in the client.)
760+
Inside `query`, `form` and `prerender` functions it is possible to use the [`redirect(...)`](@sveltejs-kit#redirect) function. It is *not* possible inside `command` functions, as you should avoid redirecting here. (If you absolutely have to, you can return a `{ redirect: location }` object and deal with it in the client.)

apps/svelte.dev/content/docs/kit/25-build-and-deploy/50-adapter-static.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export default config;
3737

3838
```js
3939
/// file: src/routes/+layout.js
40-
// This can be false if you're using a fallback (i.e. SPA mode)
40+
// If you're using a fallback (i.e. SPA mode) you don't need to prerender all
41+
// pages by setting this here, but should prerender as many as possible to
42+
// avoid large performance and SEO impacts
4143
export const prerender = true;
4244
```
4345

@@ -77,7 +79,9 @@ The directory to write static assets (the contents of `static`, plus client-side
7779

7880
### fallback
7981

80-
Specify a fallback page for [SPA mode](single-page-apps), e.g. `index.html` or `200.html` or `404.html`.
82+
To create a [single page app (SPA)](single-page-apps) you must specify the name of the fallback page to be generated by SvelteKit, which is used as the entry point for URLs that have not been prerendered. This is commonly `200.html`, but can vary depending on your deployment platform. You should avoid `index.html` where possible to avoid conflicting with a prerendered homepage.
83+
84+
> This option has large negative performance and SEO impacts. It is only recommended in certain circumstances such as wrapping the site in a mobile app. See the [single page apps](single-page-apps) documentation for more details and alternatives.
8185
8286
### precompress
8387

apps/svelte.dev/content/docs/kit/25-build-and-deploy/55-single-page-apps.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@ NOTE: do not edit this file, it is generated in apps/svelte.dev/scripts/sync-doc
33
title: Single-page apps
44
---
55

6-
You can turn any SvelteKit app, using any adapter, into a fully client-rendered single-page app (SPA) by disabling SSR at the root layout:
6+
You can turn a SvelteKit app into a fully client-rendered single-page app (SPA) by specifying a _fallback page_. This page will be served for any URLs that can't be served by other means such as returning a prerendered page.
77

8+
> [!NOTE] SPA mode has a large negative performance impact by forcing multiple network round trips (for the blank HTML document, then for the JavaScript, and then for any data needed for the page) before content can be shown. Unless you are serving the app from a local network (e.g.a mobile app that wraps a locally-served SPA) this will delay startup, especially when considering the latency of mobile devices. It also harms SEO by often causing sites to be downranked for performance (SPAs are much more likely to fail [Core Web Vitals](https://web.dev/explore/learn-core-web-vitals)), excluding search engines that don't render JS, and causing your site to receive less frequent updates from those that do. And finally, it makes your app inaccessible to users if JavaScript fails or is disabled (which happens [more often than you probably think](https://kryogenix.org/code/browser/everyonehasjs.html)).
9+
>
10+
> You can avoid these drawbacks by [prerendering](#Prerendering-individual-pages) as many pages as possible when using SPA mode (especially your homepage). If you can prerender all pages, you can simply use [static site generation](adapter-static) rather than a SPA. Otherwise, you should strongly consider using an adapter which supports server side rendering. SvelteKit has officially supported adapters for various providers with generous free tiers.
11+
12+
## Usage
13+
14+
First, disable SSR for the pages you don't want to prerender. These pages will be served via the fallback page. E.g. to serve all pages via the fallback by default, you can update the root layout as shown below. You should [opt back into prerendering individual pages and directories](#Prerendering-individual-pages) where possible.
815
```js
916
/// file: src/routes/+layout.js
1017
export const ssr = false;
1118
```
1219

13-
> [!NOTE] In most situations this is not recommended: it harms SEO, tends to slow down perceived performance, and makes your app inaccessible to users if JavaScript fails or is disabled (which happens [more often than you probably think](https://kryogenix.org/code/browser/everyonehasjs.html)).
14-
15-
If you don't have any server-side logic (i.e. `+page.server.js`, `+layout.server.js` or `+server.js` files) you can use [`adapter-static`](adapter-static) to create your SPA by adding a _fallback page_.
16-
17-
## Usage
18-
19-
Install with `npm i -D @sveltejs/adapter-static`, then add the adapter to your `svelte.config.js` with the following options:
20+
If you don't have any server-side logic (i.e. `+page.server.js`, `+layout.server.js` or `+server.js` files) you can use [`adapter-static`](adapter-static) to create your SPA. Install `adapter-static` with `npm i -D @sveltejs/adapter-static` and add it to your `svelte.config.js` with the `fallback` option:
2021

2122
```js
2223
/// file: svelte.config.js
@@ -36,10 +37,22 @@ export default config;
3637

3738
The `fallback` page is an HTML page created by SvelteKit from your page template (e.g. `app.html`) that loads your app and navigates to the correct route. For example [Surge](https://surge.sh/help/adding-a-200-page-for-client-side-routing), a static web host, lets you add a `200.html` file that will handle any requests that don't correspond to static assets or prerendered pages.
3839

39-
On some hosts it may be `index.html` or something else entirely — consult your platform's documentation.
40+
On some hosts it may be something else entirely — consult your platform's documentation. We recommend avoiding `index.html` if possible as it may conflict with prerendering.
4041

4142
> [!NOTE] Note that the fallback page will always contain absolute asset paths (i.e. beginning with `/` rather than `.`) regardless of the value of [`paths.relative`](configuration#paths), since it is used to respond to requests for arbitrary paths.
4243
44+
## Prerendering individual pages
45+
46+
If you want certain pages to be prerendered, you can re-enable `ssr` alongside `prerender` for just those parts of your app:
47+
48+
```js
49+
/// file: src/routes/my-prerendered-page/+page.js
50+
export const prerender = true;
51+
export const ssr = true;
52+
```
53+
54+
You won't need a Node server or server capable of running JavaScript to deploy this page. It will only server render your page while building your project for the purposes of outputting an `.html` page that can be served from any static web host.
55+
4356
## Apache
4457

4558
To run an SPA on [Apache](https://httpd.apache.org/), you should add a `static/.htaccess` file to route requests to the fallback page:
@@ -54,13 +67,3 @@ To run an SPA on [Apache](https://httpd.apache.org/), you should add a `static/.
5467
RewriteRule . /200.html [L]
5568
</IfModule>
5669
```
57-
58-
## Prerendering individual pages
59-
60-
If you want certain pages to be prerendered, you can re-enable `ssr` alongside `prerender` for just those parts of your app:
61-
62-
```js
63-
/// file: src/routes/my-prerendered-page/+page.js
64-
export const prerender = true;
65-
export const ssr = true;
66-
```

apps/svelte.dev/content/docs/kit/25-build-and-deploy/60-adapter-cloudflare.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export default config;
238238
/// file: wrangler.toml
239239
---site.bucket = ".cloudflare/public"---
240240
+++assets.directory = ".cloudflare/public"
241-
assets.binding = "ASSETS"+++
241+
assets.binding = "ASSETS" # Exclude this if you don't have a `main` key configured.+++
242242
```
243243
244244
### wrangler.jsonc
@@ -251,7 +251,7 @@ assets.binding = "ASSETS"+++
251251
},---
252252
+++ "assets": {
253253
"directory": ".cloudflare/public",
254-
"binding": "ASSETS"
254+
"binding": "ASSETS" // Exclude this if you don't have a `main` key configured.
255255
}+++
256256
}
257257
```

apps/svelte.dev/content/docs/kit/25-build-and-deploy/90-adapter-vercel.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,7 @@ You can't use `fs` in edge functions.
195195
You _can_ use it in serverless functions, but it won't work as expected, since files are not copied from your project into your deployment. Instead, use the [`read`]($app-server#read) function from `$app/server` to access your files. It also works inside routes deployed as edge functions by fetching the file from the deployed public assets location.
196196

197197
Alternatively, you can [prerender](page-options#prerender) the routes in question.
198+
199+
### Deployment protection
200+
201+
If using [`read`]($app-server#read) in an edge function, SvelteKit will `fetch` the file in question from your deployment. If you are using [Deployment Protection](https://vercel.com/docs/deployment-protection), you must also enable [Protection Bypass for Automation](https://vercel.com/docs/deployment-protection/methods-to-bypass-deployment-protection/protection-bypass-automation) so that the request does not result in a [401 Unauthorized](https://http.dog/401) response.

apps/svelte.dev/content/docs/kit/30-advanced/68-observability.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ To view your first trace, you'll need to set up a local collector. We'll use [Ja
7070
- Turn on the experimental flags mentioned earlier in your `svelte.config.js` file
7171
- Use your package manager to install the dependencies you'll need:
7272
```sh
73-
npm i @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node @opentelemetry/exporter-trace-oltp-proto import-in-the-middle
73+
npm i @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node @opentelemetry/exporter-trace-otlp-proto import-in-the-middle
7474
```
7575
- Create `src/instrumentation.server.js` with the following:
7676

apps/svelte.dev/content/docs/kit/30-advanced/70-packaging.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ You can create so-called declaration maps (`d.ts.map` files) by setting `"declar
243243
- `-w`/`--watch` — watch files in `src/lib` for changes and rebuild the package
244244
- `-i`/`--input` — the input directory which contains all the files of the package. Defaults to `src/lib`
245245
- `-o`/`--output` — the output directory where the processed files are written to. Your `package.json`'s `exports` should point to files inside there, and the `files` array should include that folder. Defaults to `dist`
246+
- `-p`/`--preserve-output` — prevent deletion of the output directory before packaging. Defaults to `false`, which means that the output directory will be emptied first
246247
- `-t`/`--types` — whether or not to create type definitions (`d.ts` files). We strongly recommend doing this as it fosters ecosystem library quality. Defaults to `true`
247248
- `--tsconfig` - the path to a tsconfig or jsconfig. When not provided, searches for the next upper tsconfig/jsconfig in the workspace path.
248249

0 commit comments

Comments
 (0)