Skip to content

Commit 800d171

Browse files
Sync kit docs (#1484)
sync kit docs Co-authored-by: svelte-docs-bot[bot] <196124396+svelte-docs-bot[bot]@users.noreply.github.com>
1 parent fdb4323 commit 800d171

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

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

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,20 @@ export default config;
3131

3232
To control how your routes are deployed to Vercel as functions, you can specify deployment configuration, either through the option shown above or with [`export const config`](page-options#config) inside `+server.js`, `+page(.server).js` and `+layout(.server).js` files.
3333

34-
For example you could deploy some parts of your app as [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions)...
34+
For example you could deploy one specific route as an individual serverless function, separate from the rest of your app:
3535

3636
```js
3737
/// file: about/+page.js
3838
/** @type {import('@sveltejs/adapter-vercel').Config} */
3939
export const config = {
40-
runtime: 'edge'
41-
};
42-
```
43-
44-
...and others as [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (note that by specifying `config` inside a layout, it applies to all child pages):
45-
46-
```js
47-
/// file: admin/+layout.js
48-
/** @type {import('@sveltejs/adapter-vercel').Config} */
49-
export const config = {
50-
runtime: 'nodejs22.x'
40+
split: true
5141
};
5242
```
5343

5444
The following options apply to all functions:
5545

5646
- `runtime`: `'edge'`, `'nodejs18.x'`, `'nodejs20.x'` or `'nodejs22.x'`. By default, the adapter will select the `'nodejs<version>.x'` corresponding to the Node version your project is configured to use on the Vercel dashboard
47+
> [!NOTE] This option is deprecated and will be removed in a future version, at which point all your functions will use whichever Node version is specified in the project configuration on Vercel
5748
- `regions`: an array of [edge network regions](https://vercel.com/docs/concepts/edge-network/regions) (defaulting to `["iad1"]` for serverless functions) or `'all'` if `runtime` is `edge` (its default). Note that multiple regions for serverless functions are only supported on Enterprise plans
5849
- `split`: if `true`, causes a route to be deployed as an individual function. If `split` is set to `true` at the adapter level, all routes will be deployed as individual functions
5950

@@ -65,6 +56,8 @@ And the following option apply to serverless functions:
6556
- `maxDuration`: [maximum execution duration](https://vercel.com/docs/functions/runtimes#max-duration) of the function. Defaults to `10` seconds for Hobby accounts, `15` for Pro and `900` for Enterprise
6657
- `isr`: configuration Incremental Static Regeneration, described below
6758

59+
Configuration set in a layout applies to all the routes beneath that layout, unless overridden at a more granular level.
60+
6861
If your functions need to access data in a specific region, it's recommended that they be deployed in the same region (or close to it) for optimal performance.
6962

7063
## Image Optimization
@@ -96,7 +89,7 @@ export default config;
9689

9790
Vercel supports [Incremental Static Regeneration](https://vercel.com/docs/incremental-static-regeneration) (ISR), which provides the performance and cost advantages of prerendered content with the flexibility of dynamically rendered content.
9891

99-
> Use ISR only on routes where every visitor should see the same content (much like when you prerender). If there's anything user-specific happening (like session cookies), they should happen on the client via JavaScript only to not leak sensitive information across visits
92+
> [!NOTE] Use ISR only on routes where every visitor should see the same content (much like when you prerender). If there's anything user-specific happening (like session cookies), they should happen on the client via JavaScript only to not leak sensitive information across visits
10093
10194
To add ISR to a route, include the `isr` property in your `config` object:
10295

@@ -113,7 +106,7 @@ export const config = {
113106
};
114107
```
115108

116-
> Using ISR on a route with `export const prerender = true` will have no effect, since the route is prerendered at build time
109+
> [!NOTE] Using ISR on a route with `export const prerender = true` will have no effect, since the route is prerendered at build time
117110
118111
The `expiration` property is required; all others are optional. The properties are discussed in more detail below.
119112

@@ -145,7 +138,7 @@ vercel env pull .env.development.local
145138

146139
A list of valid query parameters that contribute to the cache key. Other parameters (such as utm tracking codes) will be ignored, ensuring that they do not result in content being re-generated unnecessarily. By default, query parameters are ignored.
147140

148-
> Pages that are [prerendered](page-options#prerender) will ignore ISR configuration.
141+
> [!NOTE] Pages that are [prerendered](page-options#prerender) will ignore ISR configuration.
149142
150143
## Environment variables
151144

apps/svelte.dev/content/docs/kit/30-advanced/40-service-workers.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ The following example caches the built app and any files in `static` eagerly, an
3939

4040
import { build, files, version } from '$service-worker';
4141

42-
// The reassignment of `self` to `sw` allows you to type cast it in the process
43-
// (this is the easiest way to do it without needing additional files)
44-
const sw = /** @type {ServiceWorkerGlobalScope} */ (/** @type {unknown} */ (self));
42+
// This gives `self` the correct types
43+
const self = /** @type {ServiceWorkerGlobalScope} */ (/** @type {unknown} */ (globalThis.self));
4544

4645
// Create a unique cache name for this deployment
4746
const CACHE = `cache-${version}`;
@@ -51,7 +50,7 @@ const ASSETS = [
5150
...files // everything in `static`
5251
];
5352

54-
sw.addEventListener('install', (event) => {
53+
self.addEventListener('install', (event) => {
5554
// Create a new cache and add all files to it
5655
async function addFilesToCache() {
5756
const cache = await caches.open(CACHE);
@@ -61,7 +60,7 @@ sw.addEventListener('install', (event) => {
6160
event.waitUntil(addFilesToCache());
6261
});
6362

64-
sw.addEventListener('activate', (event) => {
63+
self.addEventListener('activate', (event) => {
6564
// Remove previous cached data from disk
6665
async function deleteOldCaches() {
6766
for (const key of await caches.keys()) {
@@ -72,7 +71,7 @@ sw.addEventListener('activate', (event) => {
7271
event.waitUntil(deleteOldCaches());
7372
});
7473

75-
sw.addEventListener('fetch', (event) => {
74+
self.addEventListener('fetch', (event) => {
7675
// ignore POST requests etc
7776
if (event.request.method !== 'GET') return;
7877

0 commit comments

Comments
 (0)