@sveltejs/kit 3.0.0-next.2 → 3.0.0-next.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/package.json +62 -36
  2. package/src/cli.js +15 -12
  3. package/src/constants.js +6 -1
  4. package/src/core/adapt/builder.js +66 -72
  5. package/src/core/adapt/index.js +17 -6
  6. package/src/core/config/index.js +134 -80
  7. package/src/core/config/options.js +295 -273
  8. package/src/core/config/types.d.ts +1 -1
  9. package/src/core/env.js +146 -16
  10. package/src/core/generate_manifest/index.js +18 -15
  11. package/src/core/postbuild/analyse.js +8 -20
  12. package/src/core/postbuild/crawl.js +22 -6
  13. package/src/core/postbuild/entities.js +8 -2
  14. package/src/core/postbuild/fallback.js +4 -2
  15. package/src/core/postbuild/prerender.js +222 -70
  16. package/src/core/postbuild/queue.js +2 -1
  17. package/src/core/sync/create_manifest_data/conflict.js +1 -1
  18. package/src/core/sync/create_manifest_data/index.js +82 -62
  19. package/src/core/sync/sync.js +40 -31
  20. package/src/core/sync/ts.js +1 -1
  21. package/src/core/sync/utils.js +22 -2
  22. package/src/core/sync/{write_non_ambient.js → write_app_types.js} +107 -58
  23. package/src/core/sync/write_client_manifest.js +14 -29
  24. package/src/core/sync/write_env.js +7 -5
  25. package/src/core/sync/write_server.js +37 -45
  26. package/src/core/sync/write_tsconfig/index.js +274 -0
  27. package/src/core/sync/write_tsconfig/test-app/package.json +7 -0
  28. package/src/core/sync/write_tsconfig/utils.js +77 -0
  29. package/src/core/sync/write_tsconfig/validate.js +128 -0
  30. package/src/core/sync/write_types/index.js +127 -123
  31. package/src/core/utils.js +30 -5
  32. package/src/exports/env/index.js +77 -0
  33. package/src/exports/env/public.d.ts +55 -0
  34. package/src/exports/hooks/index.js +3 -9
  35. package/src/exports/hooks/public.d.ts +195 -0
  36. package/src/exports/hooks/sequence.js +9 -6
  37. package/src/exports/index.js +52 -29
  38. package/src/exports/internal/client.js +5 -0
  39. package/src/exports/internal/env.js +8 -5
  40. package/src/exports/internal/index.js +1 -90
  41. package/src/exports/internal/{event.js → server/event.js} +2 -3
  42. package/src/exports/internal/server/index.js +37 -0
  43. package/src/exports/internal/server/telemetry.js +95 -0
  44. package/src/exports/internal/shared.js +90 -0
  45. package/src/exports/node/index.js +64 -22
  46. package/src/exports/params/index.js +70 -0
  47. package/src/exports/params/public.d.ts +63 -0
  48. package/src/exports/public.d.ts +50 -1733
  49. package/src/exports/remote/index.js +11 -0
  50. package/src/exports/remote/public.d.ts +519 -0
  51. package/src/exports/url.js +86 -0
  52. package/src/exports/vite/build/build_server.js +54 -65
  53. package/src/exports/vite/build/remote.js +24 -19
  54. package/src/exports/vite/build/utils.js +0 -8
  55. package/src/exports/vite/dev/index.js +218 -146
  56. package/src/exports/vite/index.js +1590 -858
  57. package/src/exports/vite/module_ids.js +2 -2
  58. package/src/exports/vite/preview/index.js +40 -32
  59. package/src/exports/vite/public.d.ts +588 -0
  60. package/src/exports/vite/utils.js +84 -46
  61. package/src/pathname.js +55 -0
  62. package/src/runner.js +15 -0
  63. package/src/runtime/app/env/internal.js +4 -4
  64. package/src/runtime/app/env/types.d.ts +1 -1
  65. package/src/runtime/app/environment/index.js +3 -3
  66. package/src/runtime/app/{forms.js → forms/index.js} +73 -42
  67. package/src/runtime/app/forms/public.d.ts +2 -0
  68. package/src/runtime/app/forms/types.d.ts +56 -0
  69. package/src/runtime/app/internal/transport.js +53 -0
  70. package/src/runtime/app/manifest/index.js +1 -0
  71. package/src/runtime/app/{navigation.js → navigation/index.js} +2 -1
  72. package/src/runtime/app/navigation/public.d.ts +237 -0
  73. package/src/runtime/app/paths/client.js +37 -37
  74. package/src/runtime/app/paths/index.js +1 -1
  75. package/src/runtime/app/paths/internal/client.js +34 -2
  76. package/src/runtime/app/paths/internal/server.js +6 -23
  77. package/src/runtime/app/paths/internal.d.ts +3 -0
  78. package/src/runtime/app/paths/public.d.ts +1 -29
  79. package/src/runtime/app/paths/server.js +36 -17
  80. package/src/runtime/app/paths/types.d.ts +11 -19
  81. package/src/runtime/app/server/index.js +2 -2
  82. package/src/runtime/app/server/public.d.ts +201 -0
  83. package/src/runtime/app/server/remote/command.js +13 -11
  84. package/src/runtime/app/server/remote/form.js +61 -39
  85. package/src/runtime/app/server/remote/prerender.js +45 -45
  86. package/src/runtime/app/server/remote/query.js +106 -108
  87. package/src/runtime/app/server/remote/requested.js +27 -19
  88. package/src/runtime/app/server/remote/shared.js +76 -76
  89. package/src/runtime/app/service-worker/index.js +24 -0
  90. package/src/runtime/app/state/client.js +4 -2
  91. package/src/runtime/app/state/index.js +7 -5
  92. package/src/runtime/app/state/public.d.ts +72 -0
  93. package/src/runtime/app/state/server.js +3 -0
  94. package/src/runtime/app/stores.js +15 -78
  95. package/src/runtime/client/bundle.js +1 -1
  96. package/src/runtime/client/client-entry.js +3 -0
  97. package/src/runtime/client/client.js +1336 -648
  98. package/src/runtime/client/constants.js +3 -6
  99. package/src/runtime/client/entry.js +24 -3
  100. package/src/runtime/client/fetcher.js +25 -25
  101. package/src/runtime/client/ndjson.js +1 -1
  102. package/src/runtime/client/parse.js +1 -1
  103. package/src/runtime/client/payload.js +17 -0
  104. package/src/runtime/client/remote-functions/cache.svelte.js +3 -1
  105. package/src/runtime/client/remote-functions/command.svelte.js +37 -61
  106. package/src/runtime/client/remote-functions/form.svelte.js +267 -178
  107. package/src/runtime/client/remote-functions/prerender.svelte.js +32 -11
  108. package/src/runtime/client/remote-functions/query/index.js +10 -17
  109. package/src/runtime/client/remote-functions/query/instance.svelte.js +64 -18
  110. package/src/runtime/client/remote-functions/query/proxy.js +5 -5
  111. package/src/runtime/client/remote-functions/query-batch.svelte.js +61 -70
  112. package/src/runtime/client/remote-functions/query-live/index.js +1 -1
  113. package/src/runtime/client/remote-functions/query-live/instance.svelte.js +63 -21
  114. package/src/runtime/client/remote-functions/query-live/iterator.js +15 -12
  115. package/src/runtime/client/remote-functions/query-live/proxy.js +2 -12
  116. package/src/runtime/client/remote-functions/shared.svelte.js +90 -65
  117. package/src/runtime/client/snapshots.js +147 -0
  118. package/src/runtime/client/state.svelte.js +94 -55
  119. package/src/runtime/client/stream.js +3 -2
  120. package/src/runtime/client/types.d.ts +13 -9
  121. package/src/runtime/client/utils.js +22 -110
  122. package/src/runtime/components/root.svelte +56 -0
  123. package/src/runtime/env/dynamic/private.js +7 -0
  124. package/src/runtime/env/dynamic/public.js +7 -0
  125. package/src/runtime/env/static/private.js +6 -0
  126. package/src/runtime/env/static/public.js +6 -0
  127. package/src/runtime/form-utils.js +172 -61
  128. package/src/runtime/pathname.js +20 -32
  129. package/src/runtime/props.svelte.js +72 -0
  130. package/src/runtime/server/constants.js +0 -3
  131. package/src/runtime/server/cookie.js +72 -55
  132. package/src/runtime/server/csrf.js +65 -0
  133. package/src/runtime/server/data/index.js +49 -53
  134. package/src/runtime/server/dev.js +22 -0
  135. package/src/runtime/server/endpoint.js +6 -7
  136. package/src/runtime/server/env_module.js +0 -5
  137. package/src/runtime/server/errors.js +160 -0
  138. package/src/runtime/server/fetch.js +32 -39
  139. package/src/runtime/server/index.js +90 -64
  140. package/src/runtime/server/internal.js +71 -0
  141. package/src/runtime/server/page/actions.js +85 -64
  142. package/src/runtime/server/page/crypto.js +2 -2
  143. package/src/runtime/server/page/csp.js +88 -104
  144. package/src/runtime/server/page/data_serializer.js +24 -25
  145. package/src/runtime/server/page/index.js +36 -53
  146. package/src/runtime/server/page/load_data.js +50 -57
  147. package/src/runtime/server/page/render.js +173 -239
  148. package/src/runtime/server/page/respond_with_error.js +17 -31
  149. package/src/runtime/server/page/serialize_data.js +2 -13
  150. package/src/runtime/server/page/server_routing.js +85 -26
  151. package/src/runtime/server/remote-functions.js +640 -0
  152. package/src/runtime/server/respond.js +190 -131
  153. package/src/runtime/server/sourcemaps.js +183 -0
  154. package/src/runtime/server/state.js +53 -0
  155. package/src/runtime/server/utils.js +13 -155
  156. package/src/runtime/shared.js +20 -40
  157. package/src/runtime/utils.js +3 -0
  158. package/src/types/ambient-private.d.ts +11 -1
  159. package/src/types/ambient.d.ts +87 -36
  160. package/src/types/global-private.d.ts +25 -25
  161. package/src/types/internal.d.ts +163 -157
  162. package/src/types/private.d.ts +41 -1
  163. package/src/utils/error.js +28 -4
  164. package/src/utils/escape.js +9 -25
  165. package/src/utils/features.js +1 -1
  166. package/src/utils/filesystem.js +1 -23
  167. package/src/utils/fork.js +7 -2
  168. package/src/utils/hash.js +21 -0
  169. package/src/utils/http.js +8 -7
  170. package/src/utils/import.js +9 -2
  171. package/src/utils/imports.js +83 -0
  172. package/src/utils/mime.js +9 -0
  173. package/src/utils/page_nodes.js +6 -7
  174. package/src/utils/params.js +67 -0
  175. package/src/utils/regex.js +9 -0
  176. package/src/utils/routing.js +145 -73
  177. package/src/utils/shared-iterator.js +5 -0
  178. package/src/utils/streaming.js +14 -4
  179. package/src/utils/url.js +33 -2
  180. package/src/version.js +1 -1
  181. package/types/index.d.ts +2616 -2433
  182. package/types/index.d.ts.map +120 -106
  183. package/src/core/sync/write_ambient.js +0 -18
  184. package/src/core/sync/write_root.js +0 -148
  185. package/src/core/sync/write_tsconfig.js +0 -250
  186. package/src/exports/internal/server.js +0 -22
  187. package/src/exports/node/polyfills.js +0 -30
  188. package/src/runtime/server/app.js +0 -9
  189. package/src/runtime/server/remote.js +0 -457
  190. package/src/runtime/shared-server.js +0 -7
  191. package/src/runtime/telemetry/otel.js +0 -21
  192. package/src/runtime/telemetry/record_span.js +0 -65
  193. package/src/types/synthetic/$lib.md +0 -5
  194. /package/src/exports/internal/{remote-functions.js → server/remote-functions.js} +0 -0
  195. /package/src/{runtime/telemetry/noop.js → telemetry.js} +0 -0
@@ -0,0 +1,588 @@
1
+ import { Adapter } from '@sveltejs/kit';
2
+ import { Options } from '@sveltejs/vite-plugin-svelte';
3
+ import {
4
+ CspDirectives,
5
+ PrerenderEntryGeneratorMismatchHandlerValue,
6
+ PrerenderHttpErrorHandlerValue,
7
+ PrerenderInvalidUrlHandlerValue,
8
+ PrerenderMissingIdHandlerValue,
9
+ PrerenderUnseenRoutesHandlerValue
10
+ } from 'types';
11
+
12
+ export * from './index.js';
13
+
14
+ // this indirection helps make the docs look pretty
15
+ type VitePluginSvelteOptions = Omit<Options, 'experimental'>;
16
+ type VitePluginSvelteOptionsExperimental = Options['experimental'];
17
+
18
+ /**
19
+ * An extension of [`vite-plugin-svelte`'s options](https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#svelte-options).
20
+ */
21
+ export interface Config extends VitePluginSvelteOptions {
22
+ /**
23
+ * Your [adapter](https://svelte.dev/docs/kit/adapters) is run when executing `vite build`. It determines how the output is converted for different platforms.
24
+ * @default undefined
25
+ */
26
+ adapter?: Adapter;
27
+ /**
28
+ * An object containing zero or more aliases used to replace values in `import` statements. These aliases are automatically passed to Vite and TypeScript.
29
+ *
30
+ * This option is deprecated. Use [subpath imports](https://svelte.dev/docs/kit/$lib) instead.
31
+ *
32
+ * > [!NOTE] You will need to run `npm run dev` to have SvelteKit automatically generate the required alias configuration in `jsconfig.json` or `tsconfig.json`.
33
+ * @deprecated
34
+ * @default {}
35
+ */
36
+ alias?: Record<string, string>;
37
+ /**
38
+ * The directory where SvelteKit keeps its stuff, including static assets (such as JS and CSS) and internally-used routes.
39
+ *
40
+ * If `paths.assets` is specified, there will be two app directories — `${paths.assets}/${appDir}` and `${paths.base}/${appDir}`.
41
+ * @default "_app"
42
+ */
43
+ appDir?: string;
44
+ /**
45
+ * [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) configuration. CSP helps to protect your users against cross-site scripting (XSS) attacks, by limiting the places resources can be loaded from. For example, a configuration like this...
46
+ *
47
+ * ```js
48
+ * /// file: vite.config.js
49
+ * import { sveltekit } from '@sveltejs/kit/vite';
50
+ * import { defineConfig } from 'vite';
51
+ *
52
+ * export default defineConfig({
53
+ * plugins: [
54
+ * sveltekit({
55
+ * csp: {
56
+ * directives: {
57
+ * 'script-src': ['self']
58
+ * },
59
+ * // must be specified with either the `report-uri` or `report-to` directives, or both
60
+ * reportOnly: {
61
+ * 'script-src': ['self'],
62
+ * 'report-uri': ['/']
63
+ * }
64
+ * }
65
+ * })
66
+ * ]
67
+ * });
68
+ * ```
69
+ *
70
+ * ...would prevent scripts loading from external sites. SvelteKit will augment the specified directives with nonces or hashes (depending on `mode`) for any inline styles and scripts it generates.
71
+ *
72
+ * To add a nonce for scripts and links manually included in `src/app.html`, you may use the placeholder `%sveltekit.nonce%` (for example `<script nonce="%sveltekit.nonce%">`).
73
+ *
74
+ * When pages are prerendered, the CSP header is added via a `<meta http-equiv>` tag (note that in this case, `frame-ancestors`, `report-uri` and `sandbox` directives will be ignored).
75
+ *
76
+ * > [!NOTE] When `mode` is `'auto'`, SvelteKit will use nonces for dynamically rendered pages and hashes for prerendered pages. Using nonces with prerendered pages is insecure and therefore forbidden.
77
+ *
78
+ * If this level of configuration is insufficient and you have more dynamic requirements, you can use the [`handle` hook](https://svelte.dev/docs/kit/hooks#handle) to roll your own CSP.
79
+ */
80
+ csp?: {
81
+ /**
82
+ * Whether to use hashes or nonces to restrict `<script>` and `<style>` elements. `'auto'` will use hashes for prerendered pages, and nonces for dynamically rendered pages.
83
+ */
84
+ mode?: 'hash' | 'nonce' | 'auto';
85
+ /**
86
+ * Directives that will be added to `Content-Security-Policy` headers.
87
+ */
88
+ directives?: CspDirectives;
89
+ /**
90
+ * Directives that will be added to `Content-Security-Policy-Report-Only` headers.
91
+ */
92
+ reportOnly?: CspDirectives;
93
+ };
94
+ /**
95
+ * Protection against [cross-site request forgery (CSRF)](https://owasp.org/www-community/attacks/csrf) attacks.
96
+ */
97
+ csrf?: {
98
+ /**
99
+ * Whether to check the incoming `origin` header for `POST`, `PUT`, `PATCH`, or `DELETE` form submissions and verify that it matches the server's origin.
100
+ *
101
+ * To allow people to make `POST`, `PUT`, `PATCH`, or `DELETE` requests with a `Content-Type` of `application/x-www-form-urlencoded`, `multipart/form-data`, or `text/plain` to your app from other origins, you will need to disable this option. Be careful!
102
+ * @default true
103
+ * @deprecated removed in 3.0. Use `trustedOrigins: ['*']` instead
104
+ */
105
+ checkOrigin?: boolean;
106
+ /**
107
+ * An array of origins that are allowed to make cross-origin form submissions to your app.
108
+ *
109
+ * Each origin should be a complete origin including protocol (e.g., `https://payment-gateway.com`).
110
+ * This is useful for allowing trusted third-party services like payment gateways or authentication providers to submit forms to your app.
111
+ *
112
+ * If the array contains `'*'`, all origins will be trusted. This is generally not recommended!
113
+ *
114
+ * > [!NOTE] Only add origins you completely trust, as this bypasses CSRF protection for those origins.
115
+ *
116
+ * CSRF checks only apply in production, not in local development.
117
+ * @default []
118
+ * @example
119
+ * ```js
120
+ * ['https://checkout.stripe.com', 'https://accounts.google.com']
121
+ * ```
122
+ */
123
+ trustedOrigins?: string[];
124
+ };
125
+ /**
126
+ * Whether or not the app is embedded inside a larger app. If `true`, SvelteKit will add its event listeners related to navigation etc on the parent of `%sveltekit.body%` instead of `window`, and will pass `params` from the server rather than inferring them from `location.pathname`.
127
+ * Note that it is generally not supported to embed multiple SvelteKit apps on the same page and use client-side SvelteKit features within them (things such as pushing to the history state assume a single instance).
128
+ * @default false
129
+ */
130
+ embedded?: boolean;
131
+ /**
132
+ * Environment variable configuration
133
+ */
134
+ env?: {
135
+ /**
136
+ * The directory to search for `.env` files.
137
+ * @default "."
138
+ */
139
+ dir?: string;
140
+ };
141
+ /** Experimental features. Here be dragons. These are not subject to semantic versioning, so breaking changes or removal can happen in any release. */
142
+ experimental?: VitePluginSvelteOptionsExperimental & {
143
+ /**
144
+ * Whether to enable the experimental remote functions feature. This feature is not yet stable and may be changed or removed at any time.
145
+ * @default false
146
+ */
147
+ remoteFunctions?: boolean;
148
+
149
+ /**
150
+ * Whether to enable the experimental forked preloading feature using Svelte's fork API.
151
+ * @default false
152
+ */
153
+ forkPreloads?: boolean;
154
+ };
155
+ /**
156
+ * Where to find various files within your project.
157
+ * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
158
+ */
159
+ files?: {
160
+ /**
161
+ * The location of your source code.
162
+ * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
163
+ * @default "src"
164
+ * @since 2.28
165
+ */
166
+ src?: string;
167
+ /**
168
+ * A place to put static files that should have stable URLs and undergo no processing, such as `favicon.ico` or `manifest.json`.
169
+ * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
170
+ * @default "static"
171
+ */
172
+ assets?: string;
173
+ hooks?: {
174
+ /**
175
+ * The location of your client [hooks](https://svelte.dev/docs/kit/hooks).
176
+ * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
177
+ * @default "src/hooks.client"
178
+ */
179
+ client?: string;
180
+ /**
181
+ * The location of your server [hooks](https://svelte.dev/docs/kit/hooks).
182
+ * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
183
+ * @default "src/hooks.server"
184
+ */
185
+ server?: string;
186
+ /**
187
+ * The location of your universal [hooks](https://svelte.dev/docs/kit/hooks).
188
+ * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
189
+ * @default "src/hooks"
190
+ * @since 2.3.0
191
+ */
192
+ universal?: string;
193
+ };
194
+ /**
195
+ * A directory containing [parameter matchers](https://svelte.dev/docs/kit/advanced-routing#Matching).
196
+ * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
197
+ * @default "src/params"
198
+ */
199
+ params?: string;
200
+ /**
201
+ * The files that define the structure of your app (see [Routing](https://svelte.dev/docs/kit/routing)).
202
+ * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
203
+ * @default "src/routes"
204
+ */
205
+ routes?: string;
206
+ /**
207
+ * The location of your service worker's entry point (see [Service workers](https://svelte.dev/docs/kit/service-workers)).
208
+ * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
209
+ * @default "src/service-worker"
210
+ */
211
+ serviceWorker?: string;
212
+ /**
213
+ * The location of the template for HTML responses.
214
+ * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
215
+ * @default "src/app.html"
216
+ */
217
+ appTemplate?: string;
218
+ /**
219
+ * The location of the template for fallback error responses.
220
+ * @deprecated this feature is still supported, but it's generally recommended to use [monorepos](https://levelup.video/tutorials/monorepos-with-pnpm) instead
221
+ * @default "src/error.html"
222
+ */
223
+ errorTemplate?: string;
224
+ };
225
+ /**
226
+ * Inline CSS inside a `<style>` block at the head of the HTML. This option is a number that specifies the maximum length of a CSS file in UTF-16 code units, as specified by the [String.length](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length) property, to be inlined. All CSS files needed for the page that are smaller than this value are merged and inlined in a `<style>` block.
227
+ *
228
+ * > [!NOTE] This results in fewer initial requests and can improve your [First Contentful Paint](https://web.dev/first-contentful-paint) score. However, it generates larger HTML output and reduces the effectiveness of browser caches. Use it advisedly.
229
+ * @default 0
230
+ */
231
+ inlineStyleThreshold?: number;
232
+ /**
233
+ * An array of file extensions that SvelteKit will treat as modules. Files with extensions that match neither `config.extensions` nor `config.moduleExtensions` will be ignored by the router.
234
+ * @default [".js", ".ts"]
235
+ */
236
+ moduleExtensions?: string[];
237
+ /**
238
+ * The directory that SvelteKit writes files to during `dev` and `build`. You should exclude this directory from version control.
239
+ * @default ".svelte-kit"
240
+ */
241
+ outDir?: string;
242
+ /**
243
+ * Options related to the build output format
244
+ */
245
+ output?: {
246
+ /**
247
+ * Whether to use the [HTTP `Link` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link) to preload assets instead of the [`<link>` HTML element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link) for non-prerendered pages.
248
+ *
249
+ * Note that some web servers such as Nginx and Apache have a default header size limit which may be easily exceeded.
250
+ * If you are using one of these web servers, you may want to leave this as `false` or configure a higher limit.
251
+ *
252
+ * @default false
253
+ * @since 3.0.0
254
+ */
255
+ linkHeaderPreload?: boolean;
256
+ /**
257
+ * SvelteKit will preload the JavaScript modules needed for the initial page to avoid import 'waterfalls', resulting in faster application startup. There
258
+ * are three strategies with different trade-offs:
259
+ * - `modulepreload` - uses `<link rel="modulepreload">`. This delivers the best results in Chromium-based browsers, in Firefox 115+, and Safari 17+. It is ignored in older browsers.
260
+ * - `preload-js` - uses `<link rel="preload">`. Prevents waterfalls in Chromium and Safari, but Chromium will parse each module twice (once as a script, once as a module). Causes modules to be requested twice in Firefox. This is a good setting if you want to maximise performance for users on iOS devices at the cost of a very slight degradation for Chromium users.
261
+ * - `preload-mjs` - uses `<link rel="preload">` but with the `.mjs` extension which prevents double-parsing in Chromium. Some static webservers will fail to serve .mjs files with a `Content-Type: application/javascript` header, which will cause your application to break. If that doesn't apply to you, this is the option that will deliver the best performance for the largest number of users, until `modulepreload` is more widely supported.
262
+ * @default "modulepreload"
263
+ * @since 1.8.4
264
+ * @deprecated removed in 3.0
265
+ */
266
+ preloadStrategy?: 'modulepreload' | 'preload-js' | 'preload-mjs';
267
+ /**
268
+ * The bundle strategy option affects how your app's JavaScript and CSS files are loaded.
269
+ * - If `'split'`, splits the app up into multiple .js/.css files so that they are loaded lazily as the user navigates around the app. This is the default, and is recommended for most scenarios.
270
+ * - If `'single'`, creates just one .js bundle and one .css file containing code for the entire app.
271
+ * - If `'inline'`, inlines all JavaScript and CSS of the entire app into the HTML. The result is usable without a server (i.e. you can just open the file in your browser).
272
+ *
273
+ * When using `'split'`, you can also adjust the bundling behaviour by setting [`output.codeSplitting`](https://rolldown.rs/reference/OutputOptions.codeSplitting) inside your Vite config's [`build.rolldownOptions`](https://vite.dev/config/build-options#build-rolldownoptions).
274
+ *
275
+ * If you want to inline your assets, you'll need to set Vite's [`build.assetsInlineLimit`](https://vite.dev/config/build-options.html#build-assetsinlinelimit) option to an appropriate size then import your assets through Vite.
276
+ *
277
+ * ```js
278
+ * /// file: vite.config.js
279
+ * import { sveltekit } from '@sveltejs/kit/vite';
280
+ * import { defineConfig } from 'vite';
281
+ *
282
+ * export default defineConfig({
283
+ * plugins: [sveltekit()],
284
+ * build: {
285
+ * // inline all imported assets
286
+ * assetsInlineLimit: Infinity
287
+ * }
288
+ * });
289
+ * ```
290
+ *
291
+ * ```svelte
292
+ * /// file: src/routes/+layout.svelte
293
+ * <script>
294
+ * // import the asset through Vite
295
+ * import favicon from './favicon.png';
296
+ * </script>
297
+ *
298
+ * <svelte:head>
299
+ * <!-- this asset will be inlined as a base64 URL -->
300
+ * <link rel="icon" href={favicon} />
301
+ * </svelte:head>
302
+ * ```
303
+ * @default 'split'
304
+ * @since 2.13.0
305
+ */
306
+ bundleStrategy?: 'split' | 'single' | 'inline';
307
+ };
308
+ paths?: {
309
+ /**
310
+ * An absolute path that your app's files are served from. This is useful if your files are served from a storage bucket of some kind.
311
+ * @default ""
312
+ */
313
+ assets?: '' | `http://${string}` | `https://${string}`;
314
+ /**
315
+ * A root-relative path that must start, but not end with `/` (e.g. `/base-path`), unless it is the empty string. This specifies where your app is served from and allows the app to live on a non-root path. Note that you need to prepend all your root-relative links with the base value or they will point to the root of your domain, not your `base` (this is how the browser works). You can use [`resolve(...)` from `$app/paths`](https://svelte.dev/docs/kit/$app-paths#resolve) for that: `<a href="{resolve('/your-page')}">Link</a>`. If you find yourself writing this often, it may make sense to extract this into a reusable component.
316
+ * @default ""
317
+ */
318
+ base?: '' | `/${string}`;
319
+ /**
320
+ * The origin of your app, used for CSRF protection and prerendering.
321
+ *
322
+ * By default, this is `undefined`, meaning SvelteKit will derive the origin from `request.url` (which is set by the adapter, and ultimately by the platform).
323
+ *
324
+ * If your app is served from an origin that isn't known at request time — for example because it's deployed to a preview deployment whose URL isn't known at build time, or because it's behind a reverse proxy that doesn't pass the `host` header — you can set this to a string like `https://my-site.com`.
325
+ *
326
+ * This is also used as the value of `url.origin` during prerendering (when unset, it defaults to `http://sveltekit-prerender`), and as the trusted origin for CSRF checks on form submissions and remote function calls.
327
+ *
328
+ * @default undefined
329
+ * @since 3.0
330
+ */
331
+ origin?: string;
332
+ /**
333
+ * Whether to use relative asset paths.
334
+ *
335
+ * If `true`, paths created with `resolve()` and `asset()` imported from `$app/paths` will be replaced with relative asset paths during server-side rendering, resulting in more portable HTML.
336
+ * If `false`, `%sveltekit.assets%` and references to build artifacts will always be root-relative paths, unless `paths.assets` is an external URL
337
+ *
338
+ * [Single-page app](https://svelte.dev/docs/kit/single-page-apps) fallback pages will always use absolute paths, regardless of this setting.
339
+ *
340
+ * If your app uses a `<base>` element, you should set this to `false`, otherwise asset URLs will incorrectly be resolved against the `<base>` URL rather than the current page.
341
+ *
342
+ * In 1.0, `undefined` was a valid value, which was set by default. In that case, if `paths.assets` was not external, SvelteKit would replace `%sveltekit.assets%` with a relative path and use relative paths to reference build artifacts, but `base` and `assets` imported from `$app/paths` would be as specified in your config.
343
+ *
344
+ * @default true
345
+ * @since 1.9.0
346
+ */
347
+ relative?: boolean;
348
+ };
349
+ /**
350
+ * See [Prerendering](https://svelte.dev/docs/kit/page-options#prerender).
351
+ */
352
+ prerender?: {
353
+ /**
354
+ * How many pages can be prerendered simultaneously. JS is single-threaded, but in cases where prerendering performance is network-bound (for example loading content from a remote CMS) this can speed things up by processing other tasks while waiting on the network response.
355
+ * @default 1
356
+ */
357
+ concurrency?: number;
358
+ /**
359
+ * Whether SvelteKit should find pages to prerender by following links from `entries`.
360
+ * @default true
361
+ */
362
+ crawl?: boolean;
363
+ /**
364
+ * An array of pages to prerender, or start crawling from (if `crawl: true`). The `*` string includes all routes containing no required `[parameters]` with optional parameters included as being empty (since SvelteKit doesn't know what value any parameters should have).
365
+ * @default ["*"]
366
+ */
367
+ entries?: Array<'*' | `/${string}`>;
368
+ /**
369
+ * How to respond to HTTP errors encountered while prerendering the app.
370
+ *
371
+ * - `'fail'` — fail the build
372
+ * - `'ignore'` - silently ignore the failure and continue
373
+ * - `'warn'` — continue, but print a warning
374
+ * - `(details) => void` — a custom error handler that takes a `details` object with `status`, `path`, `referrer`, `referenceType` and `message` properties. If you `throw` from this function, the build will fail
375
+ *
376
+ * ```js
377
+ * /// file: vite.config.js
378
+ * import { sveltekit } from '@sveltejs/kit/vite';
379
+ * import { defineConfig } from 'vite';
380
+ *
381
+ * export default defineConfig({
382
+ * plugins: [
383
+ * sveltekit({
384
+ * prerender: {
385
+ * handleHttpError: ({ path, referrer, message }) => {
386
+ * // ignore deliberate link to shiny 404 page
387
+ * if (path === '/not-found' && referrer === '/blog/how-we-built-our-404-page') {
388
+ * return;
389
+ * }
390
+ *
391
+ * // otherwise fail the build
392
+ * throw new Error(message);
393
+ * }
394
+ * }
395
+ * })
396
+ * ]
397
+ * });
398
+ * ```
399
+ *
400
+ * @default "fail"
401
+ * @since 1.15.7
402
+ */
403
+ handleHttpError?: PrerenderHttpErrorHandlerValue;
404
+ /**
405
+ * How to respond when hash links from one prerendered page to another don't correspond to an `id` on the destination page.
406
+ *
407
+ * - `'fail'` — fail the build
408
+ * - `'ignore'` - silently ignore the failure and continue
409
+ * - `'warn'` — continue, but print a warning
410
+ * - `(details) => void` — a custom error handler that takes a `details` object with `path`, `id`, `referrers` and `message` properties. If you `throw` from this function, the build will fail
411
+ *
412
+ * @default "fail"
413
+ * @since 1.15.7
414
+ */
415
+ handleMissingId?: PrerenderMissingIdHandlerValue;
416
+ /**
417
+ * How to respond when an entry generated by the `entries` export doesn't match the route it was generated from.
418
+ *
419
+ * - `'fail'` — fail the build
420
+ * - `'ignore'` - silently ignore the failure and continue
421
+ * - `'warn'` — continue, but print a warning
422
+ * - `(details) => void` — a custom error handler that takes a `details` object with `generatedFromId`, `entry`, `matchedId` and `message` properties. If you `throw` from this function, the build will fail
423
+ *
424
+ * @default "fail"
425
+ * @since 1.16.0
426
+ */
427
+ handleEntryGeneratorMismatch?: PrerenderEntryGeneratorMismatchHandlerValue;
428
+ /**
429
+ * How to respond when a route is marked as prerenderable but has not been prerendered.
430
+ *
431
+ * - `'fail'` — fail the build
432
+ * - `'ignore'` - silently ignore the failure and continue
433
+ * - `'warn'` — continue, but print a warning
434
+ * - `(details) => void` — a custom error handler that takes a `details` object with a `routes` property which contains all routes that haven't been prerendered. If you `throw` from this function, the build will fail
435
+ *
436
+ * The default behavior is to fail the build. This may be undesirable when you know that some of your routes may never be reached under certain
437
+ * circumstances such as a CMS not returning data for a specific area, resulting in certain routes never being reached.
438
+ *
439
+ * @default "fail"
440
+ * @since 2.16.0
441
+ */
442
+ handleUnseenRoutes?: PrerenderUnseenRoutesHandlerValue;
443
+ /**
444
+ * How to respond when SvelteKit encounters a URL it cannot parse while crawling prerendered HTML (for example, an AT Protocol URL such as `at://did:plc:...`).
445
+ *
446
+ * - `'fail'` — fail the build
447
+ * - `'ignore'` - silently ignore the failure and continue
448
+ * - `'warn'` — continue, but print a warning
449
+ * - `(details) => void` — a custom error handler that takes a `details` object with `href`, `referrer` and `message` properties. If you `throw` from this function, the build will fail
450
+ *
451
+ * @default "fail"
452
+ * @since 2.67.0
453
+ */
454
+ handleInvalidUrl?: PrerenderInvalidUrlHandlerValue;
455
+ };
456
+ router?: {
457
+ /**
458
+ * What type of client-side router to use.
459
+ * - `'pathname'` is the default and means the current URL pathname determines the route
460
+ * - `'hash'` means the route is determined by `location.hash`. In this case, SSR and prerendering are disabled. This is only recommended if `pathname` is not an option, for example because you don't control the webserver where your app is deployed.
461
+ * It comes with some caveats: you can't use server-side rendering (or indeed any server logic), and you have to make sure that the links in your app all start with #/, or they won't work. Beyond that, everything works exactly like a normal SvelteKit app.
462
+ *
463
+ * @default "pathname"
464
+ * @since 2.14.0
465
+ */
466
+ type?: 'pathname' | 'hash';
467
+ /**
468
+ * How to determine which route to load when navigating to a new page.
469
+ *
470
+ * By default, SvelteKit will serve a route manifest to the browser.
471
+ * When navigating, this manifest is used (along with the `reroute` hook, if it exists) to determine which components to load and which `load` functions to run.
472
+ * Because everything happens on the client, this decision can be made immediately. The drawback is that the manifest needs to be
473
+ * loaded and parsed before the first navigation can happen, which may have an impact if your app contains many routes.
474
+ *
475
+ * Alternatively, SvelteKit can determine the route on the server. This means that for every navigation to a path that has not yet been visited, the server will be asked to determine the route.
476
+ * This has several advantages:
477
+ * - The client does not need to load the routing manifest upfront, which can lead to faster initial page loads
478
+ * - The list of routes is hidden from public view
479
+ * - The server has an opportunity to intercept each navigation (for example through middleware in front of SvelteKit, such as a reverse proxy or your platform's edge functions), enabling (for example) A/B testing opaque to SvelteKit
480
+ *
481
+ * Route resolution requests are answered as soon as the route has been looked up, before the `handle` hook is invoked. To intercept them within SvelteKit itself, use the `reroute` hook, which runs for these requests too.
482
+ *
483
+ * The drawback is that for unvisited paths, resolution will take slightly longer (though this is mitigated by [preloading](https://svelte.dev/docs/kit/link-options#data-sveltekit-preload-data)).
484
+ *
485
+ * > [!NOTE] When using server-side route resolution and prerendering, the resolution is prerendered along with the route itself.
486
+ *
487
+ * @default "client"
488
+ * @since 2.17.0
489
+ */
490
+ resolution?: 'client' | 'server';
491
+ };
492
+ serviceWorker?:
493
+ | {
494
+ /**
495
+ * Whether to automatically register the service worker, if it exists.
496
+ * @default true
497
+ */
498
+ register: true;
499
+ /**
500
+ * Options for serviceWorker.register("...", options);
501
+ */
502
+ options?: RegistrationOptions;
503
+ }
504
+ | {
505
+ /**
506
+ * Whether to automatically register the service worker, if it exists.
507
+ * @default true
508
+ */
509
+ register?: false;
510
+ };
511
+ /**
512
+ * Options for enabling [OpenTelemetry](https://opentelemetry.io/) tracing for SvelteKit operations.
513
+ * @default { server: false }
514
+ */
515
+ tracing?: {
516
+ /**
517
+ * Enables server-side [OpenTelemetry](https://opentelemetry.io/) span emission for SvelteKit operations including the [`handle` hook](https://svelte.dev/docs/kit/hooks#handle), [`load` functions](https://svelte.dev/docs/kit/load), [form actions](https://svelte.dev/docs/kit/form-actions), and [remote functions](https://svelte.dev/docs/kit/remote-functions). Tracing — and more significantly, observability instrumentation — can have a nontrivial overhead, so consider whether you really need it, or if it might be more appropriate to turn it on in development and preview environments only.
518
+ * @default false
519
+ */
520
+ server?: boolean;
521
+ };
522
+ /**
523
+ * @deprecated Add configuration to `tsconfig.json` directly
524
+ */
525
+ typescript?: {
526
+ /**
527
+ * A function that allows you to edit the generated `tsconfig.json`. You can mutate the config (recommended) or return a new one.
528
+ * This is useful for extending a shared `tsconfig.json` in a monorepo root, for example.
529
+ *
530
+ * Note that any paths configured here should be relative to the generated config file, which is written to `node_modules/$app/tsconfig.json`.
531
+ *
532
+ * @default (config) => config
533
+ * @since 1.3.0
534
+ */
535
+ config?: (config: Record<string, any>) => Record<string, any> | void;
536
+ };
537
+ /**
538
+ * Client-side navigation can be buggy if you deploy a new version of your app while people are using it. If the code for the new page is already loaded, it may have stale content; if it isn't, the app's route manifest may point to a JavaScript file that no longer exists.
539
+ * SvelteKit helps you solve this problem through version management. The current version is included in data, remote, and form action responses via the `x-sveltekit-version` header, so SvelteKit can detect new deployments without polling — for example when a navigation triggers a server `load` function, or when a remote function is called. SvelteKit also checks for new versions when the tab regains focus or becomes visible.
540
+ * If SvelteKit encounters an error while loading the page and detects that a new version has been deployed (using the `name` specified here, which defaults to a timestamp of the build) it will fall back to traditional full-page navigation.
541
+ * Not all navigations will result in an error though, for example if the JavaScript for the next page is already loaded. If you still want to force a full-page navigation in these cases, use `beforeNavigate`:
542
+ * ```html
543
+ * /// file: +layout.svelte
544
+ * <script>
545
+ * import { beforeNavigate } from '$app/navigation';
546
+ * import { updated } from '$app/state';
547
+ *
548
+ * beforeNavigate(({ willUnload, to }) => {
549
+ * if (updated.current && !willUnload && to?.url) {
550
+ * location.href = to.url.href;
551
+ * }
552
+ * });
553
+ * </script>
554
+ * ```
555
+ *
556
+ * In addition to these checks, SvelteKit polls for new versions on an interval and sets [`updated.current`](https://svelte.dev/docs/kit/$app-state#updated) to `true` when it detects one. Set `pollInterval` to `0` to disable polling (the header- and event-based checks will still run).
557
+ */
558
+ version?: {
559
+ /**
560
+ * The current app version string. If specified, this must be deterministic (e.g. a commit ref rather than `Math.random()` or `Date.now().toString()`), otherwise defaults to a timestamp of the build.
561
+ *
562
+ * For example, to use the current commit hash, you could do use `git rev-parse HEAD`:
563
+ *
564
+ * ```js
565
+ * /// file: vite.config.js
566
+ * import * as child_process from 'node:child_process';
567
+ * import { sveltekit } from '@sveltejs/kit/vite';
568
+ * import { defineConfig } from 'vite';
569
+ *
570
+ * export default defineConfig({
571
+ * plugins: [
572
+ * sveltekit({
573
+ * version: {
574
+ * name: child_process.execSync('git rev-parse HEAD').toString().trim()
575
+ * }
576
+ * })
577
+ * ]
578
+ * });
579
+ * ```
580
+ */
581
+ name?: string;
582
+ /**
583
+ * The interval in milliseconds to poll for version changes. If this is `0`, no polling occurs. SvelteKit also checks for new versions on server responses (via the `x-sveltekit-version` header) and when the tab regains focus or becomes visible, so polling is only needed for long-lived sessions on a single page.
584
+ * @default 3600000
585
+ */
586
+ pollInterval?: number;
587
+ };
588
+ }