Skip to content

Commit 9e7304d

Browse files
Sync kit docs (#1330)
sync kit docs Co-authored-by: svelte-docs-bot[bot] <196124396+svelte-docs-bot[bot]@users.noreply.github.com>
1 parent 14376c3 commit 9e7304d

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ Like `+layout.js`, `+layout.server.js` can export [page options](page-options)
278278

279279
## +server
280280

281-
As well as pages, you can define routes with a `+server.js` file (sometimes referred to as an 'API route' or an 'endpoint'), which gives you full control over the response. Your `+server.js` file exports functions corresponding to HTTP verbs like `GET`, `POST`, `PATCH`, `PUT`, `DELETE`, `OPTIONS`, and `HEAD` that take a `RequestEvent` argument and return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) object.
281+
As well as pages, you can define routes with a `+server.js` file (sometimes referred to as an 'API route' or an 'endpoint'), which gives you full control over the response. Your `+server.js` file exports functions corresponding to HTTP verbs like `GET`, `POST`, `PATCH`, `PUT`, `DELETE`, `OPTIONS`, and `HEAD` that take a [`RequestEvent`](@sveltejs-kit#RequestEvent) argument and return a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) object.
282282

283283
For example we could create an `/api/random-number` route with a `GET` handler:
284284

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ 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).
131+
> [!NOTE] If all your page options are boolean or string literal values, SvelteKit will evaluate them statically. If not, it will import your `+page.js` or `+layout.js` file on the server (both at build time, and at runtime if your app isn't fully static) so it can evaluate the options. In the second case, browser-only code must not run when the module is loaded. In practice, this means you should import browser-only code in your `+page.svelte` or `+layout.svelte` file instead.
132132
133133
## csr
134134

apps/svelte.dev/content/docs/kit/25-build-and-deploy/40-adapter-node.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Development dependencies will be bundled into your app using [Rollup](https://ro
3535

3636
### Compressing responses
3737

38-
You will typically want to compress responses coming from the server. If you are already deploying your server behind a reverse proxy for SSL or load balancing, it typically results in better performance to also handle compression at that layer since Node.js is single-threaded.
38+
You will typically want to compress responses coming from the server. If you're already deploying your server behind a reverse proxy for SSL or load balancing, it typically results in better performance to also handle compression at that layer since Node.js is single-threaded.
3939

4040
However, if you're building a [custom server](#Custom-server) and do want to add a compression middleware there, note that we would recommend using [`@polka/compression`](https://www.npmjs.com/package/@polka/compression) since SvelteKit streams responses and the more popular `compression` package does not support streaming and may cause errors when used.
4141

@@ -102,7 +102,7 @@ If `adapter-node` can't correctly determine the URL of your deployment, you may
102102
103103
### `ADDRESS_HEADER` and `XFF_DEPTH`
104104

105-
The [RequestEvent](@sveltejs-kit#RequestEvent) object passed to hooks and endpoints includes an `event.getClientAddress()` function that returns the client's IP address. By default this is the connecting `remoteAddress`. If your server is behind one or more proxies (such as a load balancer), this value will contain the innermost proxy's IP address rather than the client's, so we need to specify an `ADDRESS_HEADER` to read the address from:
105+
The [`RequestEvent`](@sveltejs-kit#RequestEvent) object passed to hooks and endpoints includes an `event.getClientAddress()` function that returns the client's IP address. By default this is the connecting `remoteAddress`. If your server is behind one or more proxies (such as a load balancer), this value will contain the innermost proxy's IP address rather than the client's, so we need to specify an `ADDRESS_HEADER` to read the address from:
106106

107107
```
108108
ADDRESS_HEADER=True-Client-IP node build

apps/svelte.dev/content/docs/kit/25-build-and-deploy/99-writing-adapters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Within the `adapt` method, there are a number of things that an adapter should d
5252
- Output code that:
5353
- Imports `Server` from `${builder.getServerDirectory()}/index.js`
5454
- Instantiates the app with a manifest generated with `builder.generateManifest({ relativePath })`
55-
- Listens for requests from the platform, converts them to a standard [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) if necessary, calls the `server.respond(request, { getClientAddress })` function to generate a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) and responds with it
55+
- Listens for requests from the platform, converts them to a standard [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) if necessary, calls the `server.respond(request, { getClientAddress })` function to generate a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) and responds with it
5656
- expose any platform-specific information to SvelteKit via the `platform` option passed to `server.respond`
5757
- Globally shims `fetch` to work on the target platform, if necessary. SvelteKit provides a `@sveltejs/kit/node/polyfills` helper for platforms that can use `undici`
5858
- Bundle the output to avoid needing to install dependencies on the target platform, if necessary

apps/svelte.dev/content/docs/kit/30-advanced/20-hooks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Note that `resolve(...)` will never throw an error, it will always return a `Pro
107107

108108
### handleFetch
109109

110-
This function allows you to modify (or replace) a `fetch` request that happens inside a `load` or `action` function that runs on the server (or during pre-rendering).
110+
This function allows you to modify (or replace) a `fetch` request that happens inside a `load`, `action` or `handle` function that runs on the server (or during prerendering).
111111

112112
For example, your `load` function might make a request to a public URL like `https://api.yourapp.com` when the user performs a client-side navigation to the respective page, but during SSR it might make sense to hit the API directly (bypassing whatever proxies and load balancers sit between it and the public internet).
113113

@@ -154,7 +154,7 @@ The following can be added to `src/hooks.server.js` _and_ `src/hooks.client.js`:
154154

155155
### handleError
156156

157-
If an [unexpected error](errors#Unexpected-errors) is thrown during loading or rendering, this function will be called with the `error`, `event`, `status` code and `message`. This allows for two things:
157+
If an [unexpected error](errors#Unexpected-errors) is thrown during loading, rendering, or from an endpoint, this function will be called with the `error`, `event`, `status` code and `message`. This allows for two things:
158158

159159
- you can log the error
160160
- you can generate a custom representation of the error that is safe to show to users, omitting sensitive details like messages and stack traces. The returned value, which defaults to `{ message }`, becomes the value of `$page.error`.

apps/svelte.dev/content/docs/kit/98-reference/[email protected]

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ function text(
279279

280280
## Action
281281

282-
Shape of a form action method that is part of `export const actions = {..}` in `+page.server.js`.
282+
Shape of a form action method that is part of `export const actions = {...}` in `+page.server.js`.
283283
See [form actions](/docs/kit/form-actions) for more information.
284284

285285
<div class="ts-block">
@@ -370,7 +370,7 @@ type ActionResult<
370370

371371
## Actions
372372

373-
Shape of the `export const actions = {..}` object in `+page.server.js`.
373+
Shape of the `export const actions = {...}` object in `+page.server.js`.
374374
See [form actions](/docs/kit/form-actions) for more information.
375375

376376
<div class="ts-block">
@@ -440,7 +440,7 @@ supports?: {/*…*/}
440440

441441
<div class="ts-block-property-details">
442442

443-
Checks called during dev and build to determine whether specific features will work in production with this adapter
443+
Checks called during dev and build to determine whether specific features will work in production with this adapter.
444444

445445
<div class="ts-block-property-children"><div class="ts-block-property">
446446

@@ -452,11 +452,11 @@ read?: (details: { config: any; route: { id: string } }) => boolean;
452452

453453
<div class="ts-block-property-bullets">
454454

455-
- `config` The merged route config
455+
- `details.config` The merged route config
456456

457457
</div>
458458

459-
Test support for `read` from `$app/server`
459+
Test support for `read` from `$app/server`.
460460

461461
</div>
462462
</div></div>
@@ -473,7 +473,7 @@ emulate?: () => MaybePromise<Emulator>;
473473
<div class="ts-block-property-details">
474474

475475
Creates an `Emulator`, which allows the adapter to influence the environment
476-
during dev, build and prerendering
476+
during dev, build and prerendering.
477477

478478
</div>
479479
</div></div>
@@ -1110,7 +1110,7 @@ type HandleClientError = (input: {
11101110

11111111
## HandleFetch
11121112

1113-
The [`handleFetch`](/docs/kit/hooks#Server-hooks-handleFetch) hook allows you to modify (or replace) a `fetch` request that happens inside a `load` function that runs on the server (or during pre-rendering)
1113+
The [`handleFetch`](/docs/kit/hooks#Server-hooks-handleFetch) hook allows you to modify (or replace) a `fetch` request that happens inside a `load` function that runs on the server (or during prerendering).
11141114

11151115
<div class="ts-block">
11161116

0 commit comments

Comments
 (0)