diff --git a/apps/svelte.dev/content/docs/kit/25-build-and-deploy/90-adapter-vercel.md b/apps/svelte.dev/content/docs/kit/25-build-and-deploy/90-adapter-vercel.md index 073f5e12d2..af9d3ab4f6 100644 --- a/apps/svelte.dev/content/docs/kit/25-build-and-deploy/90-adapter-vercel.md +++ b/apps/svelte.dev/content/docs/kit/25-build-and-deploy/90-adapter-vercel.md @@ -70,13 +70,12 @@ If your functions need to access data in a specific region, it's recommended tha You may set the `images` config to control how Vercel builds your images. See the [image configuration reference](https://vercel.com/docs/build-output-api/v3/configuration#images) for full details. As an example, you may set: ```js -// @errors: 2300 2842 7031 1181 1005 1136 1128 /// file: svelte.config.js import adapter from '@sveltejs/adapter-vercel'; export default { kit: { - adapter({ + adapter: adapter({ images: { sizes: [640, 828, 1200, 1920, 3840], formats: ['image/avif', 'image/webp'], @@ -125,16 +124,16 @@ Making a `GET` or `HEAD` request with `x-prerender-revalidate: ` will for Note that the `BYPASS_TOKEN` string must be at least 32 characters long. You could generate one using the JavaScript console like so: -```console -btoa(Math.random().toString()).substring(0,32); +```js +crypto.randomUUID(); ``` Set this string as an environment variable on Vercel by logging in and going to your project then Settings > Environment Variables. For "Key" put `BYPASS_TOKEN` and for "value" use the string generated above, then hit "Save". To get this key known about for local development, you can use the [Vercel CLI](https://vercel.com/docs/cli/env) by running the `vercel env pull` command locally like so: -```console -$ vercel env pull .env.development.local +```sh +vercel env pull .env.development.local ``` ### allowQuery diff --git a/apps/svelte.dev/content/docs/kit/30-advanced/20-hooks.md b/apps/svelte.dev/content/docs/kit/30-advanced/20-hooks.md index 15f67005f1..91a56728f0 100644 --- a/apps/svelte.dev/content/docs/kit/30-advanced/20-hooks.md +++ b/apps/svelte.dev/content/docs/kit/30-advanced/20-hooks.md @@ -68,6 +68,13 @@ export async function handle({ event, resolve }) { event.locals.user = await getUserInformation(event.cookies.get('sessionid')); const response = await resolve(event); + + // Note that modifying response headers isn't always safe. + // Response objects can have immutable headers + // (e.g. Response.redirect() returned from an endpoint). + // Modifying immutable headers throws a TypeError. + // In that case, clone the response or avoid creating a + // response object with immutable headers. response.headers.set('x-custom-header', 'potato'); return response; diff --git a/apps/svelte.dev/content/docs/kit/30-advanced/70-packaging.md b/apps/svelte.dev/content/docs/kit/30-advanced/70-packaging.md index 78f656119e..b354fca1e5 100644 --- a/apps/svelte.dev/content/docs/kit/30-advanced/70-packaging.md +++ b/apps/svelte.dev/content/docs/kit/30-advanced/70-packaging.md @@ -219,6 +219,23 @@ You should think carefully about whether or not the changes you make to your pac } ``` +## Source maps + +You can create so-called declaration maps (`d.ts.map` files) by setting `"declarationMap": true` in your `tsconfig.json`. This will allow editors such as VS Code to go to the original `.ts` or `.svelte` file when using features like _Go to Definition_. This means you also need to publish your source files alongside your dist folder in a way that the relative path inside the declaration files leads to a file on disk. Assuming that you have all your library code inside `src/lib` as suggested by Svelte's CLI, this is as simple as adding `src/lib` to `files` in your `package.json`: + +```json +{ + "files": [ + "dist", + "!dist/**/*.test.*", + "!dist/**/*.spec.*", + +++"src/lib", + "!src/lib/**/*.test.*", + "!src/lib/**/*.spec.*"+++ + ] +} +``` + ## Options `svelte-package` accepts the following options: diff --git a/apps/svelte.dev/content/docs/kit/40-best-practices/03-auth.md b/apps/svelte.dev/content/docs/kit/40-best-practices/03-auth.md index daf6c48334..a2167e0b5e 100644 --- a/apps/svelte.dev/content/docs/kit/40-best-practices/03-auth.md +++ b/apps/svelte.dev/content/docs/kit/40-best-practices/03-auth.md @@ -19,6 +19,6 @@ Auth [cookies](@sveltejs-kit#Cookies) can be checked inside [server hooks](hooks ## Guides -[Lucia](https://lucia-auth.com/) is a reference for session-based web app auth. It contains example code snippets and projects for implementing session-based auth within SvelteKit and other JS projects. You can add code which follows the Lucia guide to your project with `npx sv create` when creating a new project or `npx sv add lucia` for an existing project. +[Lucia](https://lucia-auth.com/) is a good reference for session-based web app auth. It contains example code snippets and projects for implementing session-based auth within SvelteKit and other JS projects. You can add code which follows the Lucia guide to your project with `npx sv create` when creating a new project or `npx sv add lucia` for an existing project. An auth system is tightly coupled to a web framework because most of the code lies in validating user input, handling errors, and directing users to the appropriate next page. As a result, many of the generic JS auth libraries include one or more web frameworks within them. For this reason, many users will find it preferrable to follow a SvelteKit-specific guide such as the examples found in [Lucia](https://lucia-auth.com/) rather than having multiple web frameworks inside their project. diff --git a/apps/svelte.dev/content/docs/kit/98-reference/10-@sveltejs-kit.md b/apps/svelte.dev/content/docs/kit/98-reference/10-@sveltejs-kit.md index b3c855540f..a3c8095515 100644 --- a/apps/svelte.dev/content/docs/kit/98-reference/10-@sveltejs-kit.md +++ b/apps/svelte.dev/content/docs/kit/98-reference/10-@sveltejs-kit.md @@ -2351,6 +2351,14 @@ routes: SSRRoute[];
+```dts +prerendered_routes: Set; +``` + +
+
+
+ ```dts matchers: () => Promise>; ```