astro 7.2.2 → 7.2.4

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 (158) hide show
  1. package/dist/actions/handler.d.ts +6 -12
  2. package/dist/actions/handler.js +30 -40
  3. package/dist/actions/load.d.ts +12 -0
  4. package/dist/actions/load.js +55 -0
  5. package/dist/actions/runtime/entrypoints/server.js +5 -4
  6. package/dist/actions/runtime/server.js +8 -6
  7. package/dist/assets/fonts/providers/index.d.ts +1 -1
  8. package/dist/assets/fonts/providers/index.js +2 -12
  9. package/dist/assets/utils/vendor/image-size/types/heif.js +8 -3
  10. package/dist/assets/utils/vendor/image-size/types/icns.js +10 -2
  11. package/dist/assets/utils/vendor/image-size/types/jp2.js +2 -2
  12. package/dist/assets/utils/vendor/image-size/types/jxl.js +5 -2
  13. package/dist/assets/utils/vendor/image-size/types/utils.d.ts +1 -1
  14. package/dist/assets/utils/vendor/image-size/types/utils.js +20 -6
  15. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  16. package/dist/container/environment.d.ts +20 -0
  17. package/dist/container/environment.js +106 -0
  18. package/dist/container/index.js +73 -37
  19. package/dist/content/content-layer.js +3 -3
  20. package/dist/content/data-store-writer.d.ts +7 -10
  21. package/dist/content/data-store-writer.js +62 -27
  22. package/dist/content/data-store.d.ts +20 -3
  23. package/dist/content/data-store.js +28 -7
  24. package/dist/content/mutable-data-store.js +15 -10
  25. package/dist/content/runtime.d.ts +3 -2
  26. package/dist/content/runtime.js +43 -26
  27. package/dist/core/app/app.d.ts +0 -2
  28. package/dist/core/app/app.js +0 -7
  29. package/dist/core/app/base.d.ts +32 -20
  30. package/dist/core/app/base.js +79 -73
  31. package/dist/core/app/dev-facade.d.ts +27 -0
  32. package/dist/core/app/dev-facade.js +51 -0
  33. package/dist/core/app/entrypoints/index.d.ts +0 -1
  34. package/dist/core/app/entrypoints/index.js +0 -2
  35. package/dist/core/app/entrypoints/virtual/dev.js +24 -19
  36. package/dist/core/app/node.js +13 -14
  37. package/dist/core/app/prepare-response.d.ts +1 -1
  38. package/dist/core/app/validate-headers.js +7 -3
  39. package/dist/core/build/app.d.ts +31 -6
  40. package/dist/core/build/app.js +31 -13
  41. package/dist/core/build/environment.d.ts +25 -0
  42. package/dist/core/build/environment.js +157 -0
  43. package/dist/core/cache/handler.d.ts +13 -7
  44. package/dist/core/cache/handler.js +55 -51
  45. package/dist/core/cache/provider.d.ts +4 -0
  46. package/dist/core/cache/provider.js +15 -0
  47. package/dist/core/constants.d.ts +0 -11
  48. package/dist/core/constants.js +1 -5
  49. package/dist/core/dev/dev.js +1 -1
  50. package/dist/core/environment/dev-nonrunnable.d.ts +6 -0
  51. package/dist/core/environment/dev-nonrunnable.js +170 -0
  52. package/dist/core/environment/index.d.ts +90 -0
  53. package/dist/core/environment/index.js +12 -0
  54. package/dist/core/environment/production.d.ts +6 -0
  55. package/dist/core/environment/production.js +117 -0
  56. package/dist/core/errors/build-handler.d.ts +5 -10
  57. package/dist/core/errors/build-handler.js +11 -17
  58. package/dist/core/errors/default-handler.d.ts +4 -9
  59. package/dist/core/errors/default-handler.js +92 -107
  60. package/dist/core/errors/dev-handler.d.ts +7 -11
  61. package/dist/core/errors/dev-handler.js +71 -69
  62. package/dist/core/errors/errors-data.d.ts +18 -0
  63. package/dist/core/errors/errors-data.js +7 -0
  64. package/dist/core/errors/handler.d.ts +22 -3
  65. package/dist/core/errors/handler.js +25 -0
  66. package/dist/core/fetch/default-handler.d.ts +15 -8
  67. package/dist/core/fetch/default-handler.js +12 -34
  68. package/dist/core/fetch/features.d.ts +23 -0
  69. package/dist/core/fetch/features.js +27 -0
  70. package/dist/core/fetch/fetch-state.d.ts +52 -7
  71. package/dist/core/fetch/fetch-state.js +99 -92
  72. package/dist/core/fetch/index.d.ts +9 -2
  73. package/dist/core/fetch/index.js +18 -79
  74. package/dist/core/fetch/vite-plugin.js +2 -1
  75. package/dist/core/i18n/domain.js +4 -11
  76. package/dist/core/i18n/handler.d.ts +28 -13
  77. package/dist/core/i18n/handler.js +100 -100
  78. package/dist/core/logger/manifest-logger.d.ts +31 -0
  79. package/dist/core/logger/manifest-logger.js +37 -0
  80. package/dist/core/manifest/ambient-source.d.ts +2 -0
  81. package/dist/core/manifest/ambient-source.js +4 -0
  82. package/dist/core/manifest/ambient.d.ts +16 -0
  83. package/dist/core/manifest/ambient.js +22 -0
  84. package/dist/core/manifest/derived.d.ts +3 -0
  85. package/dist/core/manifest/derived.js +10 -0
  86. package/dist/core/manifest/memo.d.ts +31 -0
  87. package/dist/core/manifest/memo.js +47 -0
  88. package/dist/core/messages/runtime.js +1 -1
  89. package/dist/core/middleware/astro-middleware.d.ts +25 -35
  90. package/dist/core/middleware/astro-middleware.js +61 -81
  91. package/dist/core/middleware/load.d.ts +19 -0
  92. package/dist/core/middleware/load.js +36 -0
  93. package/dist/core/middleware/sequence.js +15 -7
  94. package/dist/core/pages/handler.d.ts +18 -25
  95. package/dist/core/pages/handler.js +68 -84
  96. package/dist/core/redirects/render.js +3 -8
  97. package/dist/core/render/index.d.ts +0 -1
  98. package/dist/core/render/index.js +0 -2
  99. package/dist/core/render/route-cache.d.ts +6 -1
  100. package/dist/core/render/route-cache.js +11 -1
  101. package/dist/core/rewrites/handler.d.ts +4 -6
  102. package/dist/core/rewrites/handler.js +19 -20
  103. package/dist/core/routing/default.d.ts +2 -0
  104. package/dist/core/routing/default.js +7 -1
  105. package/dist/core/routing/dev.d.ts +1 -3
  106. package/dist/core/routing/dev.js +12 -5
  107. package/dist/core/routing/handler.d.ts +6 -16
  108. package/dist/core/routing/handler.js +126 -164
  109. package/dist/core/routing/helpers.d.ts +7 -1
  110. package/dist/core/routing/helpers.js +21 -0
  111. package/dist/core/routing/match-request.d.ts +10 -0
  112. package/dist/core/routing/match-request.js +46 -0
  113. package/dist/core/routing/route-table.d.ts +34 -0
  114. package/dist/core/routing/route-table.js +41 -0
  115. package/dist/core/routing/trailing-slash-handler.d.ts +4 -14
  116. package/dist/core/routing/trailing-slash-handler.js +39 -50
  117. package/dist/core/server-islands/mappings.d.ts +6 -0
  118. package/dist/core/server-islands/mappings.js +12 -0
  119. package/dist/core/session/driver.d.ts +4 -0
  120. package/dist/core/session/driver.js +14 -0
  121. package/dist/core/session/handler.d.ts +1 -1
  122. package/dist/core/session/handler.js +8 -8
  123. package/dist/core/session/provider-disabled.js +2 -2
  124. package/dist/entrypoints/prerender.js +5 -1
  125. package/dist/i18n/middleware.d.ts +4 -4
  126. package/dist/i18n/middleware.js +3 -3
  127. package/dist/manifest/serialized.d.ts +1 -0
  128. package/dist/manifest/serialized.js +9 -2
  129. package/dist/runtime/prerender/static-paths.d.ts +14 -2
  130. package/dist/runtime/prerender/static-paths.js +4 -3
  131. package/dist/types/public/config.d.ts +433 -241
  132. package/dist/vite-plugin-app/createAstroServerApp.js +22 -18
  133. package/dist/vite-plugin-app/environment.d.ts +18 -0
  134. package/dist/vite-plugin-app/environment.js +210 -0
  135. package/dist/vite-plugin-app/handle-request.d.ts +30 -0
  136. package/dist/vite-plugin-app/handle-request.js +129 -0
  137. package/dist/vite-plugin-app/index.d.ts +1 -1
  138. package/dist/vite-plugin-app/index.js +1 -1
  139. package/package.json +14 -7
  140. package/src/core/README.md +37 -0
  141. package/src/core/manifest/ambient-source.ts +9 -0
  142. package/src/types/README.md +5 -0
  143. package/dist/container/pipeline.d.ts +0 -14
  144. package/dist/container/pipeline.js +0 -78
  145. package/dist/core/app/dev/app.d.ts +0 -31
  146. package/dist/core/app/dev/app.js +0 -80
  147. package/dist/core/app/dev/pipeline.d.ts +0 -17
  148. package/dist/core/app/dev/pipeline.js +0 -133
  149. package/dist/core/app/pipeline.d.ts +0 -14
  150. package/dist/core/app/pipeline.js +0 -123
  151. package/dist/core/base-pipeline.d.ts +0 -183
  152. package/dist/core/base-pipeline.js +0 -293
  153. package/dist/core/build/pipeline.d.ts +0 -38
  154. package/dist/core/build/pipeline.js +0 -202
  155. package/dist/vite-plugin-app/app.d.ts +0 -62
  156. package/dist/vite-plugin-app/app.js +0 -237
  157. package/dist/vite-plugin-app/pipeline.d.ts +0 -25
  158. package/dist/vite-plugin-app/pipeline.js +0 -189
@@ -82,11 +82,14 @@ export type ServerConfig = {
82
82
  * hostname is allowed.
83
83
  *
84
84
  * ```js
85
- * {
85
+ * // astro.config.mjs
86
+ * import { defineConfig } from 'astro/config';
87
+ *
88
+ * export default defineConfig({
86
89
  * server: {
87
- * allowedHosts: ['staging.example.com', 'qa.example.com']
90
+ * allowedHosts: ['staging.example.com', 'qa.example.com']
88
91
  * }
89
- * }
92
+ * });
90
93
  * ```
91
94
  */
92
95
  allowedHosts?: string[] | true;
@@ -110,9 +113,12 @@ export type ServerConfig = {
110
113
  * Pass a full URL string (e.g. "http://example.com") or a pathname (e.g. "/about") to specify the URL to open.
111
114
  *
112
115
  * ```js
113
- * {
116
+ * // astro.config.mjs
117
+ * import { defineConfig } from 'astro/config';
118
+ *
119
+ * export default defineConfig({
114
120
  * server: { open: "/about" }
115
- * }
121
+ * });
116
122
  * ```
117
123
  */
118
124
  open?: string | boolean;
@@ -140,9 +146,12 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
140
146
  * Your final, deployed URL. Astro uses this full URL to generate your sitemap and canonical URLs in your final build. It is strongly recommended that you set this configuration to get the most out of Astro.
141
147
  *
142
148
  * ```js
143
- * {
149
+ * // astro.config.mjs
150
+ * import { defineConfig } from 'astro/config';
151
+ *
152
+ * export default defineConfig({
144
153
  * site: 'https://www.my-site.dev'
145
- * }
154
+ * });
146
155
  * ```
147
156
  */
148
157
  site?: string;
@@ -156,9 +165,12 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
156
165
  * In the example below, `astro dev` will start your server at `/docs`.
157
166
  *
158
167
  * ```js
159
- * {
168
+ * // astro.config.mjs
169
+ * import { defineConfig } from 'astro/config';
170
+ *
171
+ * export default defineConfig({
160
172
  * base: '/docs'
161
- * }
173
+ * });
162
174
  * ```
163
175
  *
164
176
  * When using this option, all of your static asset imports and URLs should add the base as a prefix. You can access this value via `import.meta.env.BASE_URL`.
@@ -171,19 +183,25 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
171
183
  *
172
184
  * In the example below, the values of `import.meta.env.BASE_URL` and `config.base` when processed will both be `/docs`:
173
185
  * ```js
174
- * {
175
- * base: '/docs/',
176
- * trailingSlash: "never"
177
- * }
186
+ * // astro.config.mjs
187
+ * import { defineConfig } from 'astro/config';
188
+ *
189
+ * export default defineConfig({
190
+ * base: '/docs/',
191
+ * trailingSlash: "never"
192
+ * });
178
193
  * ```
179
194
  *
180
195
  * In the example below, the values of `import.meta.env.BASE_URL` and `config.base` when processed will both be `/docs/`:
181
196
  *
182
197
  * ```js
183
- * {
184
- * base: '/docs',
185
- * trailingSlash: "always"
186
- * }
198
+ * // astro.config.mjs
199
+ * import { defineConfig } from 'astro/config';
200
+ *
201
+ * export default defineConfig({
202
+ * base: '/docs',
203
+ * trailingSlash: "always"
204
+ * });
187
205
  * ```
188
206
  */
189
207
  base?: string;
@@ -206,10 +224,13 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
206
224
  * See your hosting platform's documentation for more information. You cannot use Astro [redirects](https://docs.astro.build/en/reference/configuration-reference/#redirects) for this use case at this point.
207
225
  *
208
226
  * ```js
209
- * {
227
+ * // astro.config.mjs
228
+ * import { defineConfig } from 'astro/config';
229
+ *
230
+ * export default defineConfig({
210
231
  * // Example: Require a trailing slash during development
211
232
  * trailingSlash: 'always'
212
- * }
233
+ * });
213
234
  * ```
214
235
  */
215
236
  trailingSlash?: 'always' | 'never' | 'ignore';
@@ -219,7 +240,8 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
219
240
  * @type {Record<string, RedirectConfig>}
220
241
  * @default `{}`
221
242
  * @version 2.9.0
222
- * @description Specify a mapping of redirects where the key is the route to match
243
+ * @description
244
+ * Specify a mapping of redirects where the key is the route to match
223
245
  * and the value is the path to redirect to.
224
246
  *
225
247
  * You can redirect both static and dynamic routes, but only to the same kind of route.
@@ -227,6 +249,9 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
227
249
  *
228
250
  *
229
251
  * ```js
252
+ * // astro.config.mjs
253
+ * import { defineConfig } from 'astro/config';
254
+ *
230
255
  * export default defineConfig({
231
256
  * redirects: {
232
257
  * '/old': '/new',
@@ -237,8 +262,8 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
237
262
  * destination: 'https://example.com/news'
238
263
  * },
239
264
  * // '/product1/', '/product1' // Note, this is not supported
240
- * }
241
- * })
265
+ * }
266
+ * });
242
267
  * ```
243
268
  *
244
269
  *
@@ -252,6 +277,9 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
252
277
  * You can customize the [redirection status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages) using an object in the redirect config:
253
278
  *
254
279
  * ```js
280
+ * // astro.config.mjs
281
+ * import { defineConfig } from 'astro/config';
282
+ *
255
283
  * export default defineConfig({
256
284
  * redirects: {
257
285
  * '/other': {
@@ -259,9 +287,7 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
259
287
  * destination: '/place',
260
288
  * },
261
289
  * }
262
- * })
263
- *
264
- *
290
+ * });
265
291
  * ```
266
292
  */
267
293
  redirects?: Record<string, RedirectConfig>;
@@ -279,11 +305,12 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
279
305
  * - `'server'` - Use server-side rendering (SSR) for all pages by default, always outputting a server-rendered site.
280
306
  *
281
307
  * ```js
308
+ * // astro.config.mjs
282
309
  * import { defineConfig } from 'astro/config';
283
310
  *
284
311
  * export default defineConfig({
285
312
  * output: 'static'
286
- * })
313
+ * });
287
314
  * ```
288
315
  */
289
316
  output?: 'static' | 'server';
@@ -299,11 +326,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
299
326
  * See our [on-demand rendering guide](https://docs.astro.build/en/guides/on-demand-rendering/) for more on Astro's server rendering options.
300
327
  *
301
328
  * ```js
329
+ * // astro.config.mjs
330
+ * import { defineConfig } from 'astro/config';
302
331
  * import netlify from '@astrojs/netlify';
303
- * {
332
+ *
333
+ * export default defineConfig({
304
334
  * // Example: Build for Netlify serverless deployment
305
335
  * adapter: netlify(),
306
- * }
336
+ * });
307
337
  * ```
308
338
  */
309
339
  adapter?: AstroIntegration;
@@ -318,12 +348,15 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
318
348
  * Read our [Integrations Guide](https://docs.astro.build/en/guides/integrations/) for help getting started with Astro Integrations.
319
349
  *
320
350
  * ```js
351
+ * // astro.config.mjs
352
+ * import { defineConfig } from 'astro/config';
321
353
  * import react from '@astrojs/react';
322
354
  * import mdx from '@astrojs/mdx';
323
- * {
355
+ *
356
+ * export default defineConfig({
324
357
  * // Example: Add React + MDX support to Astro
325
358
  * integrations: [react(), mdx()]
326
- * }
359
+ * });
327
360
  * ```
328
361
  */
329
362
  integrations?: Array<AstroIntegration | (AstroIntegration | false | undefined | null)[] | false | undefined | null>;
@@ -334,19 +367,24 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
334
367
  * @type {string}
335
368
  * @default `"."` (current working directory)
336
369
  * @summary Set the project root. The project root is the directory where your Astro project (and all `src`, `public` and `package.json` files) live.
337
- * @description You should only provide this option if you run the `astro` CLI commands in a directory other than the project root directory. Usually, this option is provided via the CLI instead of the Astro config file, since Astro needs to know your project root before it can locate your config file.
370
+ * @description
371
+ * You should only provide this option if you run the `astro` CLI commands in a directory other than the project root directory. Usually, this option is provided via the CLI instead of the Astro config file, since Astro needs to know your project root before it can locate your config file.
338
372
  *
339
373
  * If you provide a relative path (ex: `--root: './my-project'`) Astro will resolve it against your current working directory.
340
374
  *
341
- * #### Examples
342
- *
343
375
  * ```js
344
- * {
376
+ * // astro.config.mjs
377
+ * import { defineConfig } from 'astro/config';
378
+ *
379
+ * export default defineConfig({
345
380
  * root: './my-project-directory'
346
- * }
381
+ * });
347
382
  * ```
383
+ *
384
+ * The following example sets the root directory using the CLI:
385
+ *
348
386
  * ```bash
349
- * $ astro build --root ./my-project-directory
387
+ * astro build --root ./my-project-directory
350
388
  * ```
351
389
  */
352
390
  root?: string;
@@ -355,14 +393,18 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
355
393
  * @name srcDir
356
394
  * @type {string}
357
395
  * @default `"./src"`
358
- * @description Set the directory that Astro will read your site from.
396
+ * @description
397
+ * Set the directory that Astro will read your site from.
359
398
  *
360
399
  * The value can be either an absolute file system path or a path relative to the project root.
361
400
  *
362
401
  * ```js
363
- * {
402
+ * // astro.config.mjs
403
+ * import { defineConfig } from 'astro/config';
404
+ *
405
+ * export default defineConfig({
364
406
  * srcDir: './www'
365
- * }
407
+ * });
366
408
  * ```
367
409
  */
368
410
  srcDir?: string;
@@ -377,9 +419,12 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
377
419
  * The value can be either an absolute file system path or a path relative to the project root.
378
420
  *
379
421
  * ```js
380
- * {
422
+ * // astro.config.mjs
423
+ * import { defineConfig } from 'astro/config';
424
+ *
425
+ * export default defineConfig({
381
426
  * publicDir: './my-custom-publicDir-directory'
382
- * }
427
+ * });
383
428
  * ```
384
429
  */
385
430
  publicDir?: string;
@@ -389,14 +434,18 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
389
434
  * @type {string}
390
435
  * @default `"./dist"`
391
436
  * @see build.server
392
- * @description Set the directory that `astro build` writes your final build to.
437
+ * @description
438
+ * Set the directory that `astro build` writes your final build to.
393
439
  *
394
440
  * The value can be either an absolute file system path or a path relative to the project root.
395
441
  *
396
442
  * ```js
397
- * {
443
+ * // astro.config.mjs
444
+ * import { defineConfig } from 'astro/config';
445
+ *
446
+ * export default defineConfig({
398
447
  * outDir: './my-custom-build-directory'
399
- * }
448
+ * });
400
449
  * ```
401
450
  */
402
451
  outDir?: string;
@@ -405,14 +454,18 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
405
454
  * @name cacheDir
406
455
  * @type {string}
407
456
  * @default `"./node_modules/.astro"`
408
- * @description Set the directory for caching build artifacts. Files in this directory will be used in subsequent builds to speed up the build time.
457
+ * @description
458
+ * Set the directory for caching build artifacts. Files in this directory will be used in subsequent builds to speed up the build time.
409
459
  *
410
460
  * The value can be either an absolute file system path or a path relative to the project root.
411
461
  *
412
462
  * ```js
413
- * {
463
+ * // astro.config.mjs
464
+ * import { defineConfig } from 'astro/config';
465
+ *
466
+ * export default defineConfig({
414
467
  * cacheDir: './my-custom-cache-directory'
415
- * }
468
+ * });
416
469
  * ```
417
470
  */
418
471
  cacheDir?: string;
@@ -432,11 +485,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
432
485
  * Setting this option to `false` disables HTML compression and preserves all whitespace.
433
486
  *
434
487
  * ```js
435
- * {
488
+ * // astro.config.mjs
489
+ * import { defineConfig } from 'astro/config';
490
+ *
491
+ * export default defineConfig({
436
492
  * compressHTML: true
437
493
  * // or:
438
494
  * // compressHTML: false
439
- * }
495
+ * });
440
496
  * ```
441
497
  */
442
498
  compressHTML?: boolean | 'jsx';
@@ -471,9 +527,12 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
471
527
  * - `ignore`: silently build using the highest-priority route when conflicts occur
472
528
  *
473
529
  * ```js
474
- * {
530
+ * // astro.config.mjs
531
+ * import { defineConfig } from 'astro/config';
532
+ *
533
+ * export default defineConfig({
475
534
  * prerenderConflictBehavior: 'error'
476
- * }
535
+ * });
477
536
  * ```
478
537
  */
479
538
  prerenderConflictBehavior?: 'error' | 'warn' | 'ignore';
@@ -490,23 +549,29 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
490
549
  * #### Examples
491
550
  *
492
551
  * ```js
493
- * {
552
+ * // astro.config.mjs
553
+ * import { defineConfig } from 'astro/config';
554
+ *
555
+ * export default defineConfig({
494
556
  * vite: {
495
557
  * ssr: {
496
558
  * // Example: Force a broken package to skip SSR processing, if needed
497
559
  * external: ['broken-npm-package'],
498
560
  * }
499
561
  * }
500
- * }
562
+ * });
501
563
  * ```
502
564
  *
503
565
  * ```js
504
- * {
566
+ * // astro.config.mjs
567
+ * import { defineConfig } from 'astro/config';
568
+ *
569
+ * export default defineConfig({
505
570
  * vite: {
506
571
  * // Example: Add custom vite plugins directly to your Astro project
507
572
  * plugins: [myPlugin()],
508
573
  * }
509
- * }
574
+ * });
510
575
  * ```
511
576
  */
512
577
  vite?: ViteUserConfig;
@@ -528,12 +593,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
528
593
  *
529
594
  * ```js
530
595
  * // astro.config.mjs
596
+ * import { defineConfig } from 'astro/config';
597
+ *
531
598
  * export default defineConfig({
532
599
  * output: "server",
533
600
  * security: {
534
601
  * checkOrigin: false
535
602
  * }
536
- * })
603
+ * });
537
604
  * ```
538
605
  */
539
606
  security?: {
@@ -575,7 +642,10 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
575
642
  * - `**.example.com` - matches any subdomain depth (e.g., both `sub.example.com` and `deep.sub.example.com`)
576
643
  *
577
644
  * ```js
578
- * {
645
+ * // astro.config.mjs
646
+ * import { defineConfig } from 'astro/config';
647
+ *
648
+ * export default defineConfig({
579
649
  * security: {
580
650
  * // Example: Allow any subdomain of example.com on https
581
651
  * allowedDomains: [
@@ -590,18 +660,21 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
590
660
  * }
591
661
  * ]
592
662
  * }
593
- * }
663
+ * });
594
664
  * ```
595
665
  *
596
666
  * In some specific contexts (e.g., applications behind trusted reverse proxies with dynamic domains), you may need to allow all domains. To do this, use an empty object:
597
667
  *
598
668
  * ```js
599
- * {
669
+ * // astro.config.mjs
670
+ * import { defineConfig } from 'astro/config';
671
+ *
672
+ * export default defineConfig({
600
673
  * security: {
601
674
  * // Allow any domain - use this only when necessary
602
675
  * allowedDomains: [{}]
603
676
  * }
604
- * }
677
+ * });
605
678
  * ```
606
679
  *
607
680
  * When not configured, `X-Forwarded-Host` headers are not trusted and will be ignored.
@@ -623,11 +696,13 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
623
696
  *
624
697
  * ```js
625
698
  * // astro.config.mjs
699
+ * import { defineConfig } from 'astro/config';
700
+ *
626
701
  * export default defineConfig({
627
702
  * security: {
628
703
  * actionBodySizeLimit: 10 * 1024 * 1024 // 10 MB
629
704
  * }
630
- * })
705
+ * });
631
706
  * ```
632
707
  */
633
708
  actionBodySizeLimit?: number;
@@ -647,11 +722,13 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
647
722
  *
648
723
  * ```js
649
724
  * // astro.config.mjs
725
+ * import { defineConfig } from 'astro/config';
726
+ *
650
727
  * export default defineConfig({
651
728
  * security: {
652
729
  * serverIslandBodySizeLimit: 10 * 1024 * 1024 // 10 MB
653
730
  * }
654
- * })
731
+ * });
655
732
  * ```
656
733
  */
657
734
  serverIslandBodySizeLimit?: number;
@@ -1157,12 +1234,15 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1157
1234
  * - `'preserve'`: Astro will generate HTML files exactly as they appear in your source folder. (e.g. `src/pages/about.astro` builds `/about.html` and `src/pages/about/index.astro` builds the file `/about/index.html`)
1158
1235
  *
1159
1236
  * ```js
1160
- * {
1237
+ * // astro.config.mjs
1238
+ * import { defineConfig } from 'astro/config';
1239
+ *
1240
+ * export default defineConfig({
1161
1241
  * build: {
1162
1242
  * // Example: Generate `page.html` instead of `page/index.html` during build.
1163
1243
  * format: 'file'
1164
1244
  * }
1165
- * }
1245
+ * });
1166
1246
  * ```
1167
1247
  *
1168
1248
  *
@@ -1192,12 +1272,15 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1192
1272
  * This value is relative to the `outDir`.
1193
1273
  *
1194
1274
  * ```js
1195
- * {
1275
+ * // astro.config.mjs
1276
+ * import { defineConfig } from 'astro/config';
1277
+ *
1278
+ * export default defineConfig({
1196
1279
  * output: 'server',
1197
1280
  * build: {
1198
1281
  * client: './client'
1199
1282
  * }
1200
- * }
1283
+ * });
1201
1284
  * ```
1202
1285
  */
1203
1286
  client?: string;
@@ -1212,11 +1295,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1212
1295
  * This value is relative to the `outDir`.
1213
1296
  *
1214
1297
  * ```js
1215
- * {
1298
+ * // astro.config.mjs
1299
+ * import { defineConfig } from 'astro/config';
1300
+ *
1301
+ * export default defineConfig({
1216
1302
  * build: {
1217
1303
  * server: './server'
1218
1304
  * }
1219
- * }
1305
+ * });
1220
1306
  * ```
1221
1307
  */
1222
1308
  server?: string;
@@ -1231,11 +1317,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1231
1317
  * Specifies the directory in the build output where Astro-generated assets (bundled JS and CSS for example) should live.
1232
1318
  *
1233
1319
  * ```js
1234
- * {
1320
+ * // astro.config.mjs
1321
+ * import { defineConfig } from 'astro/config';
1322
+ *
1323
+ * export default defineConfig({
1235
1324
  * build: {
1236
1325
  * assets: '_custom'
1237
1326
  * }
1238
- * }
1327
+ * });
1239
1328
  * ```
1240
1329
  */
1241
1330
  assets?: string;
@@ -1254,11 +1343,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1254
1343
  * To fetch all assets uploaded to the same domain (e.g. `https://cdn.example.com/_astro/...`), set `assetsPrefix` to the root domain as a string (regardless of your `base` configuration):
1255
1344
  *
1256
1345
  * ```js
1257
- * {
1346
+ * // astro.config.mjs
1347
+ * import { defineConfig } from 'astro/config';
1348
+ *
1349
+ * export default defineConfig({
1258
1350
  * build: {
1259
1351
  * assetsPrefix: 'https://cdn.example.com'
1260
1352
  * }
1261
- * }
1353
+ * });
1262
1354
  * ```
1263
1355
  *
1264
1356
  * **Added in:** `astro@4.5.0`
@@ -1267,7 +1359,10 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1267
1359
  * In this case, a `fallback` property is required and will be used by default for any other files.
1268
1360
  *
1269
1361
  * ```js
1270
- * {
1362
+ * // astro.config.mjs
1363
+ * import { defineConfig } from 'astro/config';
1364
+ *
1365
+ * export default defineConfig({
1271
1366
  * build: {
1272
1367
  * assetsPrefix: {
1273
1368
  * 'js': 'https://js.cdn.example.com',
@@ -1276,7 +1371,7 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1276
1371
  * 'fallback': 'https://cdn.example.com'
1277
1372
  * }
1278
1373
  * }
1279
- * }
1374
+ * });
1280
1375
  * ```
1281
1376
  *
1282
1377
  */
@@ -1295,11 +1390,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1295
1390
  * detects that the file is a JavaScript module.
1296
1391
  *
1297
1392
  * ```js
1298
- * {
1393
+ * // astro.config.mjs
1394
+ * import { defineConfig } from 'astro/config';
1395
+ *
1396
+ * export default defineConfig({
1299
1397
  * build: {
1300
1398
  * serverEntry: 'main.mjs'
1301
1399
  * }
1302
- * }
1400
+ * });
1303
1401
  * ```
1304
1402
  */
1305
1403
  serverEntry?: string;
@@ -1318,11 +1416,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1318
1416
  * configuration files for redirects and do not need/want HTML based redirects.
1319
1417
  *
1320
1418
  * ```js
1321
- * {
1419
+ * // astro.config.mjs
1420
+ * import { defineConfig } from 'astro/config';
1421
+ *
1422
+ * export default defineConfig({
1322
1423
  * build: {
1323
1424
  * redirects: false
1324
1425
  * }
1325
- * }
1426
+ * });
1326
1427
  * ```
1327
1428
  */
1328
1429
  redirects?: boolean;
@@ -1339,11 +1440,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1339
1440
  * - `'never'` - project styles are sent in external stylesheets
1340
1441
  *
1341
1442
  * ```js
1342
- * {
1343
- * build: {
1344
- * inlineStylesheets: `never`,
1345
- * },
1346
- * }
1443
+ * // astro.config.mjs
1444
+ * import { defineConfig } from 'astro/config';
1445
+ *
1446
+ * export default defineConfig({
1447
+ * build: {
1448
+ * inlineStylesheets: `never`,
1449
+ * },
1450
+ * });
1347
1451
  * ```
1348
1452
  */
1349
1453
  inlineStylesheets?: 'always' | 'auto' | 'never';
@@ -1362,11 +1466,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1362
1466
  * If the number is set too high, page rendering may slow down due to insufficient memory resources and because JS is single-threaded.
1363
1467
  *
1364
1468
  * ```js
1365
- * {
1469
+ * // astro.config.mjs
1470
+ * import { defineConfig } from 'astro/config';
1471
+ *
1472
+ * export default defineConfig({
1366
1473
  * build: {
1367
1474
  * concurrency: 2
1368
1475
  * }
1369
- * }
1476
+ * });
1370
1477
  * ```
1371
1478
  *
1372
1479
  * :::caution[Breaking changes possible]
@@ -1384,20 +1491,29 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1384
1491
  * Customize the Astro dev server, used by both `astro dev` and `astro preview`.
1385
1492
  *
1386
1493
  * ```js
1387
- * {
1494
+ * // astro.config.mjs
1495
+ * import { defineConfig } from 'astro/config';
1496
+ *
1497
+ * export default defineConfig({
1388
1498
  * server: { port: 1234, host: true}
1389
- * }
1499
+ * });
1390
1500
  * ```
1391
1501
  *
1392
1502
  * To set different configuration based on the command run ("dev", "preview") a function can also be passed to this configuration option.
1393
1503
  *
1394
1504
  * ```js
1395
- * {
1505
+ * // astro.config.mjs
1506
+ * import { defineConfig } from 'astro/config';
1507
+ *
1508
+ * export default defineConfig({
1396
1509
  * // Example: Use the function syntax to customize based on command
1397
1510
  * server: ({ command }) => ({ port: command === 'dev' ? 4321 : 4000 })
1398
- * }
1511
+ * });
1399
1512
  * ```
1400
1513
  */
1514
+ server?: ServerConfig | ((options: {
1515
+ command: 'dev' | 'preview';
1516
+ }) => ServerConfig);
1401
1517
  /**
1402
1518
  * @docs
1403
1519
  * @name server.host
@@ -1421,9 +1537,12 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1421
1537
  * If the given port is already in use, Astro will automatically try the next available port.
1422
1538
  *
1423
1539
  * ```js
1424
- * {
1540
+ * // astro.config.mjs
1541
+ * import { defineConfig } from 'astro/config';
1542
+ *
1543
+ * export default defineConfig({
1425
1544
  * server: { port: 8080 }
1426
- * }
1545
+ * });
1427
1546
  * ```
1428
1547
  */
1429
1548
  /**
@@ -1438,11 +1557,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1438
1557
  * hostname is allowed.
1439
1558
  *
1440
1559
  * ```js
1441
- * {
1560
+ * // astro.config.mjs
1561
+ * import { defineConfig } from 'astro/config';
1562
+ *
1563
+ * export default defineConfig({
1442
1564
  * server: {
1443
- * allowedHosts: ['staging.example.com', 'qa.example.com']
1565
+ * allowedHosts: ['staging.example.com', 'qa.example.com']
1444
1566
  * }
1445
- * }
1567
+ * });
1446
1568
  * ```
1447
1569
  */
1448
1570
  /**
@@ -1457,9 +1579,12 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1457
1579
  * Pass a full URL string (e.g. "http://example.com") or a pathname (e.g. "/about") to specify the URL to open.
1458
1580
  *
1459
1581
  * ```js
1460
- * {
1582
+ * // astro.config.mjs
1583
+ * import { defineConfig } from 'astro/config';
1584
+ *
1585
+ * export default defineConfig({
1461
1586
  * server: { open: "/about" }
1462
- * }
1587
+ * });
1463
1588
  * ```
1464
1589
  */
1465
1590
  /**
@@ -1471,9 +1596,6 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1471
1596
  * @description
1472
1597
  * Set custom HTTP response headers to be sent in `astro dev` and `astro preview`.
1473
1598
  */
1474
- server?: ServerConfig | ((options: {
1475
- command: 'dev' | 'preview';
1476
- }) => ServerConfig);
1477
1599
  /**
1478
1600
  * @docs
1479
1601
  * @kind heading
@@ -1632,13 +1754,13 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1632
1754
  * import vercel from '@astrojs/vercel'
1633
1755
  *
1634
1756
  * export default defineConfig({
1635
- * adapter: vercel()
1757
+ * adapter: vercel(),
1636
1758
  * session: {
1637
1759
  * driver: sessionDrivers.redis({
1638
1760
  * url: process.env.REDIS_URL
1639
1761
  * }),
1640
1762
  * }
1641
- * })
1763
+ * });
1642
1764
  * ```
1643
1765
  *
1644
1766
  * :::note
@@ -1660,15 +1782,17 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1660
1782
  * The driver-specific options to use for session storage. The options depend on the driver you are using. See the [Unstorage documentation](https://unstorage.unjs.io/drivers)
1661
1783
  * for more information on the options available for each driver.
1662
1784
  *
1663
- * ```js title="astro.config.mjs" ins={4-6}
1664
- * {
1665
- * session: {
1666
- * driver: "redis",
1667
- * options: {
1668
- * url: process.env.REDIS_URL
1669
- * },
1670
- * }
1671
- * }
1785
+ * ```js title="astro.config.mjs" ins={6-8}
1786
+ * import { defineConfig } from 'astro/config';
1787
+ *
1788
+ * export default defineConfig({
1789
+ * session: {
1790
+ * driver: "redis",
1791
+ * options: {
1792
+ * url: process.env.REDIS_URL
1793
+ * },
1794
+ * }
1795
+ * });
1672
1796
  * ```
1673
1797
  */
1674
1798
  /**
@@ -1682,27 +1806,30 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1682
1806
  * The session cookie configuration. If set to a string, it will be used as the cookie name.
1683
1807
  * Alternatively, you can pass an object with additional options. These will be merged with the defaults.
1684
1808
  *
1685
- * ```js title="astro.config.mjs" ins={3-4}
1686
- * {
1687
- * session: {
1688
- * // If set to a string, it will be used as the cookie name.
1689
- * cookie: "my-session-cookie",
1690
- * }
1691
- * }
1809
+ * ```js title="astro.config.mjs" ins={5-6}
1810
+ * import { defineConfig } from 'astro/config';
1692
1811
  *
1812
+ * export default defineConfig({
1813
+ * session: {
1814
+ * // If set to a string, it will be used as the cookie name.
1815
+ * cookie: "my-session-cookie",
1816
+ * }
1817
+ * });
1693
1818
  * ```
1694
1819
  *
1695
- * ```js title="astro.config.mjs" ins={4-8}
1696
- * {
1697
- * session: {
1698
- * // If set to an object, it will be used as the cookie options.
1699
- * cookie: {
1700
- * name: "my-session-cookie",
1701
- * sameSite: "lax",
1702
- * secure: true,
1703
- * }
1704
- * }
1705
- * }
1820
+ * ```js title="astro.config.mjs" ins={5-10}
1821
+ * import { defineConfig } from 'astro/config';
1822
+ *
1823
+ * export default defineConfig({
1824
+ * session: {
1825
+ * // If set to an object, it will be used as the cookie options.
1826
+ * cookie: {
1827
+ * name: "my-session-cookie",
1828
+ * sameSite: "lax",
1829
+ * secure: true,
1830
+ * }
1831
+ * }
1832
+ * });
1706
1833
  * ```
1707
1834
  */
1708
1835
  /**
@@ -1719,13 +1846,15 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1719
1846
  * Set `session.ttl` to add a default expiration period for your session values. Passing a `ttl` option to [`session.set()`](https://docs.astro.build/en/reference/api-reference/#sessionset) will override the global default
1720
1847
  * for that individual entry.
1721
1848
  *
1722
- * ```js title="astro.config.mjs" ins={3-4}
1723
- * {
1724
- * session: {
1725
- * // Set a default expiration period of 1 hour (3600 seconds)
1726
- * ttl: 3600,
1727
- * }
1728
- * }
1849
+ * ```js title="astro.config.mjs" ins={5-6}
1850
+ * import { defineConfig } from 'astro/config';
1851
+ *
1852
+ * export default defineConfig({
1853
+ * session: {
1854
+ * // Set a default expiration period of 1 hour (3600 seconds)
1855
+ * ttl: 3600,
1856
+ * }
1857
+ * });
1729
1858
  * ```
1730
1859
  * :::note
1731
1860
  * Setting a value for `ttl` does not automatically delete the value from storage after the time limit has passed.
@@ -1795,9 +1924,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1795
1924
  * This value defaults to `true` when using the `<ClientRouter />` router. Otherwise, the default value is `false`.
1796
1925
  *
1797
1926
  * ```js
1798
- * prefetch: {
1799
- * prefetchAll: true
1800
- * }
1927
+ * // astro.config.mjs
1928
+ * import { defineConfig } from 'astro/config';
1929
+ *
1930
+ * export default defineConfig({
1931
+ * prefetch: {
1932
+ * prefetchAll: true,
1933
+ * },
1934
+ * });
1801
1935
  * ```
1802
1936
  *
1803
1937
  * When set to `true`, you can disable prefetching individually by setting `data-astro-prefetch="false"` on any individual links.
@@ -1844,15 +1978,18 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1844
1978
  * Set the endpoint to use for image optimization in dev and SSR. The `entrypoint` property can be set to `undefined` to use the default image endpoint.
1845
1979
  *
1846
1980
  * ```js
1847
- * {
1981
+ * // astro.config.mjs
1982
+ * import { defineConfig } from 'astro/config';
1983
+ *
1984
+ * export default defineConfig({
1848
1985
  * image: {
1849
1986
  * // Example: Use a custom image endpoint at `/custom_endpoint`
1850
1987
  * endpoint: {
1851
- * route: '/custom_endpoint',
1852
- * entrypoint: 'src/my_endpoint.ts',
1853
- * },
1988
+ * route: '/custom_endpoint',
1989
+ * entrypoint: 'src/my_endpoint.ts',
1990
+ * },
1854
1991
  * },
1855
- * }
1992
+ * });
1856
1993
  * ```
1857
1994
  */
1858
1995
  endpoint?: {
@@ -1873,24 +2010,27 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
1873
2010
  * The service entrypoint can be either one of the included services, or a third-party package.
1874
2011
  *
1875
2012
  * ```js
1876
- * {
2013
+ * // astro.config.mjs
2014
+ * import { defineConfig } from 'astro/config';
2015
+ *
2016
+ * export default defineConfig({
1877
2017
  * image: {
1878
2018
  * // Example: Enable the Sharp-based image service with a custom config
1879
2019
  * service: {
1880
- * entrypoint: 'astro/assets/services/sharp',
1881
- * config: {
1882
- * limitInputPixels: false,
1883
- * webp: {
1884
- * effort: 6,
1885
- * alphaQuality: 80,
1886
- * },
1887
- * jpeg: {
1888
- * mozjpeg: true,
1889
- * },
2020
+ * entrypoint: 'astro/assets/services/sharp',
2021
+ * config: {
2022
+ * limitInputPixels: false,
2023
+ * webp: {
2024
+ * effort: 6,
2025
+ * alphaQuality: 80,
2026
+ * },
2027
+ * jpeg: {
2028
+ * mozjpeg: true,
2029
+ * },
1890
2030
  * },
1891
- * },
2031
+ * },
1892
2032
  * },
1893
- * }
2033
+ * });
1894
2034
  * ```
1895
2035
  */
1896
2036
  service?: ImageServiceConfig;
@@ -2002,12 +2142,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2002
2142
  *
2003
2143
  * ```js
2004
2144
  * // astro.config.mjs
2005
- * {
2145
+ * import { defineConfig } from 'astro/config';
2146
+ *
2147
+ * export default defineConfig({
2006
2148
  * image: {
2007
2149
  * // Example: Allow remote image optimization from a single domain
2008
2150
  * domains: ['astro.build'],
2009
2151
  * },
2010
- * }
2152
+ * });
2011
2153
  * ```
2012
2154
  */
2013
2155
  domains?: string[];
@@ -2027,7 +2169,10 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2027
2169
  * 4. pathname
2028
2170
  *
2029
2171
  * ```js
2030
- * {
2172
+ * // astro.config.mjs
2173
+ * import { defineConfig } from 'astro/config';
2174
+ *
2175
+ * export default defineConfig({
2031
2176
  * image: {
2032
2177
  * // Example: allow processing all images from your aws s3 bucket
2033
2178
  * remotePatterns: [{
@@ -2035,7 +2180,7 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2035
2180
  * hostname: '**.amazonaws.com',
2036
2181
  * }],
2037
2182
  * },
2038
- * }
2183
+ * });
2039
2184
  * ```
2040
2185
  *
2041
2186
  * You can use wildcards to define the permitted `hostname` and `pathname` values as described below. Otherwise, only the exact values provided will be configured.
@@ -2189,12 +2334,15 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2189
2334
  * - `false` - do not apply syntax highlighting.
2190
2335
 
2191
2336
  * ```js
2192
- * {
2337
+ * // astro.config.mjs
2338
+ * import { defineConfig } from 'astro/config';
2339
+ *
2340
+ * export default defineConfig({
2193
2341
  * markdown: {
2194
2342
  * // Example: Switch to use prism for syntax highlighting in Markdown
2195
2343
  * syntaxHighlight: 'prism',
2196
2344
  * }
2197
- * }
2345
+ * });
2198
2346
  * ```
2199
2347
  *
2200
2348
  * For more control over syntax highlighting, you can instead specify a configuration object with the properties listed below.
@@ -2253,12 +2401,15 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2253
2401
  * Pass [remark plugins](https://github.com/remarkjs/remark) to customize how your Markdown is built. You can import and apply the plugin function (recommended), or pass the plugin name as a string.
2254
2402
  *
2255
2403
  * ```js
2404
+ * // astro.config.mjs
2405
+ * import { defineConfig } from 'astro/config';
2256
2406
  * import remarkToc from 'remark-toc';
2257
- * {
2407
+ *
2408
+ * export default defineConfig({
2258
2409
  * markdown: {
2259
2410
  * remarkPlugins: [ [remarkToc, { heading: "contents"} ] ]
2260
2411
  * }
2261
- * }
2412
+ * });
2262
2413
  * ```
2263
2414
  */
2264
2415
  remarkPlugins?: RemarkPlugins;
@@ -2273,12 +2424,15 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2273
2424
  * Pass [rehype plugins](https://github.com/remarkjs/remark-rehype) to customize how your Markdown's output HTML is processed. You can import and apply the plugin function (recommended), or pass the plugin name as a string.
2274
2425
  *
2275
2426
  * ```js
2427
+ * // astro.config.mjs
2428
+ * import { defineConfig } from 'astro/config';
2276
2429
  * import { rehypeAccessibleEmojis } from 'rehype-accessible-emojis';
2277
- * {
2430
+ *
2431
+ * export default defineConfig({
2278
2432
  * markdown: {
2279
2433
  * rehypePlugins: [rehypeAccessibleEmojis]
2280
2434
  * }
2281
- * }
2435
+ * });
2282
2436
  * ```
2283
2437
  */
2284
2438
  rehypePlugins?: RehypePlugins;
@@ -2295,11 +2449,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2295
2449
  * Astro uses [GitHub-flavored Markdown](https://github.com/remarkjs/remark-gfm) by default. To disable this, set the `gfm` flag to `false`:
2296
2450
  *
2297
2451
  * ```js
2298
- * {
2452
+ * // astro.config.mjs
2453
+ * import { defineConfig } from 'astro/config';
2454
+ *
2455
+ * export default defineConfig({
2299
2456
  * markdown: {
2300
2457
  * gfm: false,
2301
2458
  * }
2302
- * }
2459
+ * });
2303
2460
  * ```
2304
2461
  */
2305
2462
  gfm?: boolean;
@@ -2333,12 +2490,15 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2333
2490
  * Pass options to [remark-rehype](https://github.com/remarkjs/remark-rehype#api).
2334
2491
  *
2335
2492
  * ```js
2336
- * {
2493
+ * // astro.config.mjs
2494
+ * import { defineConfig } from 'astro/config';
2495
+ *
2496
+ * export default defineConfig({
2337
2497
  * markdown: {
2338
2498
  * // Example: Translate the footnotes text to another language, here are the default English values
2339
2499
  * remarkRehype: { footnoteLabel: "Footnotes", footnoteBackLabel: "Back to reference 1"},
2340
2500
  * },
2341
- * };
2501
+ * });
2342
2502
  * ```
2343
2503
  */
2344
2504
  remarkRehype?: RemarkRehype;
@@ -2442,16 +2602,19 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2442
2602
  * The following example configures your content fallback strategy to redirect unavailable pages in `/pt-br/` to their `es` version, and unavailable pages in `/fr/` to their `en` version. Unavailable `/es/` pages will return a 404.
2443
2603
  *
2444
2604
  * ```js
2605
+ * // astro.config.mjs
2606
+ * import { defineConfig } from 'astro/config';
2607
+ *
2445
2608
  * export default defineConfig({
2446
- * i18n: {
2447
- * defaultLocale: "en",
2448
- * locales: ["en", "fr", "pt-br", "es"],
2449
- * fallback: {
2450
- * pt: "es",
2451
- * fr: "en"
2452
- * }
2453
- * }
2454
- * })
2609
+ * i18n: {
2610
+ * defaultLocale: "en",
2611
+ * locales: ["en", "fr", "pt-br", "es"],
2612
+ * fallback: {
2613
+ * "pt-br": "es",
2614
+ * fr: "en"
2615
+ * }
2616
+ * }
2617
+ * });
2455
2618
  * ```
2456
2619
  */
2457
2620
  fallback?: [TLocales] extends [never] ? Record<string, string> : {
@@ -2468,29 +2631,35 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2468
2631
  * Controls the routing strategy to determine your site URLs. Set this based on your folder/URL path configuration for your default language.
2469
2632
  *
2470
2633
  * ```js
2634
+ * // astro.config.mjs
2635
+ * import { defineConfig } from 'astro/config';
2636
+ *
2471
2637
  * export default defineConfig({
2472
- * i18n: {
2473
- * defaultLocale: "en",
2474
- * locales: ["en", "fr"],
2475
- * routing: {
2476
- * prefixDefaultLocale: false,
2477
- * redirectToDefaultLocale: true,
2478
- * fallbackType: "redirect",
2479
- * }
2480
- * }
2481
- * })
2638
+ * i18n: {
2639
+ * defaultLocale: "en",
2640
+ * locales: ["en", "fr"],
2641
+ * routing: {
2642
+ * prefixDefaultLocale: false,
2643
+ * redirectToDefaultLocale: true,
2644
+ * fallbackType: "redirect",
2645
+ * }
2646
+ * }
2647
+ * });
2482
2648
  * ```
2483
2649
  *
2484
2650
  * Since 4.6.0, this option can also be set to `manual`. When this routing strategy is enabled, Astro will **disable** its i18n middleware and no other `routing` options (e.g. `prefixDefaultLocale`) may be configured. You will be responsible for writing your own routing logic, or executing Astro's i18n middleware manually alongside your own.
2485
2651
  *
2486
2652
  * ```js
2653
+ * // astro.config.mjs
2654
+ * import { defineConfig } from 'astro/config';
2655
+ *
2487
2656
  * export default defineConfig({
2488
- * i18n: {
2489
- * defaultLocale: "en",
2490
- * locales: ["en", "fr"],
2491
- * routing: "manual"
2492
- * }
2493
- * })
2657
+ * i18n: {
2658
+ * defaultLocale: "en",
2659
+ * locales: ["en", "fr"],
2660
+ * routing: "manual"
2661
+ * }
2662
+ * });
2494
2663
  * ```
2495
2664
  *
2496
2665
  */
@@ -2513,15 +2682,18 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2513
2682
  * Localized folders are used for every language, including the default.
2514
2683
  *
2515
2684
  * ```js
2685
+ * // astro.config.mjs
2686
+ * import { defineConfig } from 'astro/config';
2687
+ *
2516
2688
  * export default defineConfig({
2517
- * i18n: {
2518
- * defaultLocale: "en",
2519
- * locales: ["en", "fr", "pt-br", "es"],
2520
- * routing: {
2521
- * prefixDefaultLocale: true,
2522
- * }
2523
- * }
2524
- * })
2689
+ * i18n: {
2690
+ * defaultLocale: "en",
2691
+ * locales: ["en", "fr", "pt-br", "es"],
2692
+ * routing: {
2693
+ * prefixDefaultLocale: true,
2694
+ * }
2695
+ * }
2696
+ * });
2525
2697
  * ```
2526
2698
  */
2527
2699
  prefixDefaultLocale?: boolean;
@@ -2540,17 +2712,19 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2540
2712
  * Set `redirectToDefaultLocale: true` to enable this automatic redirection at the root of your site:
2541
2713
  * ```js
2542
2714
  * // astro.config.mjs
2715
+ * import { defineConfig } from 'astro/config';
2716
+ *
2543
2717
  * export default defineConfig({
2544
2718
  * i18n:{
2545
2719
  * defaultLocale: "en",
2546
- * locales: ["en", "fr"],
2720
+ * locales: ["en", "fr"],
2547
2721
  * routing: {
2548
2722
  * prefixDefaultLocale: true,
2549
2723
  * redirectToDefaultLocale: true
2550
2724
  * }
2551
2725
  * }
2552
- * })
2553
- *```
2726
+ * });
2727
+ * ```
2554
2728
  * */
2555
2729
  redirectToDefaultLocale?: boolean;
2556
2730
  /**
@@ -2573,19 +2747,21 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2573
2747
  *
2574
2748
  * ```js
2575
2749
  * //astro.config.mjs
2750
+ * import { defineConfig } from 'astro/config';
2751
+ *
2576
2752
  * export default defineConfig({
2577
- * i18n: {
2753
+ * i18n: {
2578
2754
  * defaultLocale: "en",
2579
2755
  * locales: ["en", "fr"],
2580
2756
  * routing: {
2581
- * prefixDefaultLocale: false,
2582
- * fallbackType: "rewrite",
2757
+ * prefixDefaultLocale: false,
2758
+ * fallbackType: "rewrite",
2583
2759
  * },
2584
2760
  * fallback: {
2585
- * fr: "en",
2761
+ * fr: "en",
2586
2762
  * }
2587
2763
  * },
2588
- * })
2764
+ * });
2589
2765
  * ```
2590
2766
  */
2591
2767
  fallbackType?: 'redirect' | 'rewrite';
@@ -2608,21 +2784,23 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2608
2784
  * ```js
2609
2785
  * //astro.config.mjs
2610
2786
  * export default defineConfig({
2611
- * site: "https://example.com",
2612
- * output: "server", // required, with no prerendered pages
2613
- * adapter: node({
2614
- * mode: 'standalone',
2615
- * }),
2616
- * i18n: {
2787
+ * site: "https://example.com",
2788
+ * output: "server", // required, with no prerendered pages
2789
+ * adapter: node({
2790
+ * mode: 'standalone',
2791
+ * }),
2792
+ * i18n: {
2617
2793
  * defaultLocale: "en",
2618
2794
  * locales: ["en", "fr", "pt-br", "es"],
2619
- * prefixDefaultLocale: false,
2795
+ * routing: {
2796
+ * prefixDefaultLocale: false,
2797
+ * },
2620
2798
  * domains: {
2621
2799
  * fr: "https://fr.example.com",
2622
2800
  * es: "https://example.es"
2623
2801
  * }
2624
2802
  * },
2625
- * })
2803
+ * });
2626
2804
  * ```
2627
2805
  *
2628
2806
  * Both page routes built and URLs returned by the `astro:i18n` helper functions [`getAbsoluteLocaleUrl()`](https://docs.astro.build/en/reference/modules/astro-i18n/#getabsolutelocaleurl) and [`getAbsoluteLocaleUrlList()`](https://docs.astro.build/en/reference/modules/astro-i18n/#getabsolutelocaleurllist) will use the options set in `i18n.domains`.
@@ -2669,7 +2847,7 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2669
2847
  * API_SECRET: envField.string({ context: "server", access: "secret" }),
2670
2848
  * }
2671
2849
  * }
2672
- * })
2850
+ * });
2673
2851
  * ```
2674
2852
  */
2675
2853
  schema?: EnvSchema;
@@ -2696,7 +2874,7 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2696
2874
  * },
2697
2875
  * validateSecrets: true
2698
2876
  * }
2699
- * })
2877
+ * });
2700
2878
  * ```
2701
2879
  */
2702
2880
  validateSecrets?: boolean;
@@ -2713,6 +2891,9 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2713
2891
  *
2714
2892
  * See our guide for more information on [using custom fonts in Astro](https://docs.astro.build/en/guides/fonts/).
2715
2893
  */
2894
+ fonts?: [TFontProviders] extends [never] ? Array<FontFamily> : {
2895
+ [K in keyof TFontProviders]: FontFamily<TFontProviders[K]>;
2896
+ };
2716
2897
  /**
2717
2898
  * @docs
2718
2899
  * @name font.provider
@@ -2722,6 +2903,7 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2722
2903
  * The source of your font files. You can use a [built-in provider](https://docs.astro.build/en/reference/font-provider-reference/#built-in-providers) or write your own [custom provider](https://docs.astro.build/en/reference/font-provider-reference/#building-a-font-provider):
2723
2904
  *
2724
2905
  * ```js
2906
+ * // astro.config.mjs
2725
2907
  * import { defineConfig, fontProviders } from "astro/config";
2726
2908
  *
2727
2909
  * export default defineConfig({
@@ -2932,9 +3114,6 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2932
3114
  * variationSettings: "'xhgt' 0.7"
2933
3115
  * ```
2934
3116
  */
2935
- fonts?: [TFontProviders] extends [never] ? Array<FontFamily> : {
2936
- [K in keyof TFontProviders]: FontFamily<TFontProviders[K]>;
2937
- };
2938
3117
  /**
2939
3118
  * @docs
2940
3119
  * @kind heading
@@ -2950,16 +3129,16 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2950
3129
  *
2951
3130
  * ```js
2952
3131
  * // astro.config.mjs
2953
- * import { memoryCache } from 'astro/config';
3132
+ * import { defineConfig, memoryCache } from 'astro/config';
2954
3133
  *
2955
- * {
3134
+ * export default defineConfig({
2956
3135
  * cache: {
2957
3136
  * provider: memoryCache(),
2958
3137
  * },
2959
3138
  * routeRules: {
2960
3139
  * '/blog/[...path]': { maxAge: 300, swr: 60 },
2961
3140
  * },
2962
- * }
3141
+ * });
2963
3142
  * ```
2964
3143
  *
2965
3144
  * Use `Astro.cache.set()` in routes and `context.cache.set()` in middleware
@@ -2978,6 +3157,7 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2978
3157
  * Use the provider's config function to get type-safe configuration:
2979
3158
  *
2980
3159
  * ```js
3160
+ * // astro.config.mjs
2981
3161
  * import { defineConfig, memoryCache } from 'astro/config';
2982
3162
  *
2983
3163
  * export default defineConfig({
@@ -3002,15 +3182,15 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
3002
3182
  *
3003
3183
  * ```js
3004
3184
  * // astro.config.mjs
3005
- * import { memoryCache } from 'astro/config';
3185
+ * import { defineConfig, memoryCache } from 'astro/config';
3006
3186
  *
3007
- * {
3187
+ * export default defineConfig({
3008
3188
  * cache: { provider: memoryCache() },
3009
3189
  * routeRules: {
3010
3190
  * '/api/[...path]': { swr: 600 },
3011
3191
  * '/products/[...slug]': { maxAge: 3600, tags: ['products'] },
3012
3192
  * },
3013
- * }
3193
+ * });
3014
3194
  * ```
3015
3195
  */
3016
3196
  routeRules?: RouteRules;
@@ -3067,15 +3247,17 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
3067
3247
  *
3068
3248
  * ```js
3069
3249
  * // astro.config.mjs
3070
- * {
3250
+ * import { defineConfig } from 'astro/config';
3251
+ *
3252
+ * export default defineConfig({
3071
3253
  * prefetch: {
3072
3254
  * prefetchAll: true,
3073
3255
  * defaultStrategy: 'viewport',
3074
3256
  * },
3075
- * experimental: {
3076
- * clientPrerender: true,
3077
- * },
3078
- * }
3257
+ * experimental: {
3258
+ * clientPrerender: true,
3259
+ * },
3260
+ * });
3079
3261
  * ```
3080
3262
  *
3081
3263
  * Continue to use the `data-astro-prefetch` attribute on any `<a />` link on your site to opt in to prefetching.
@@ -3099,11 +3281,14 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
3099
3281
  * When enabled, this feature will generate and add JSON schemas to the `.astro` directory in your project. These files can be used by the Astro language server to provide Intellisense inside content files (`.md`, `.mdx`, `.mdoc`).
3100
3282
  *
3101
3283
  * ```js
3102
- * {
3284
+ * // astro.config.mjs
3285
+ * import { defineConfig } from 'astro/config';
3286
+ *
3287
+ * export default defineConfig({
3103
3288
  * experimental: {
3104
3289
  * contentIntellisense: true,
3105
3290
  * },
3106
- * }
3291
+ * });
3107
3292
  * ```
3108
3293
  *
3109
3294
  * To use this feature with the Astro VS Code extension, you must also enable the `astro.content-intellisense` option in your VS Code settings. For editors using the Astro language server directly, pass the `contentIntellisense: true` initialization parameter to enable this feature.
@@ -3122,6 +3307,7 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
3122
3307
  * allowing you to edit files directly in the browser and have those changes reflected in your local file system.
3123
3308
  *
3124
3309
  * ```js
3310
+ * // astro.config.mjs
3125
3311
  * import { defineConfig } from 'astro/config';
3126
3312
  *
3127
3313
  * export default defineConfig({
@@ -3146,12 +3332,15 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
3146
3332
  * and better performance while maintaining visual quality.
3147
3333
  *
3148
3334
  * ```js
3149
- * {
3335
+ * // astro.config.mjs
3336
+ * import { defineConfig } from 'astro/config';
3337
+ *
3338
+ * export default defineConfig({
3150
3339
  * experimental: {
3151
3340
  * // Enable with defaults
3152
3341
  * svgOptimizer: svgoOptimizer()
3153
3342
  * }
3154
- * }
3343
+ * });
3155
3344
  * ```
3156
3345
  *
3157
3346
  * See the [experimental SVG optimization docs](https://docs.astro.build/en/reference/experimental-flags/svg-optimization/) for more information.
@@ -3176,6 +3365,7 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
3176
3365
  * is recommended for broad adapter compatibility.
3177
3366
  *
3178
3367
  * ```js
3368
+ * // astro.config.mjs
3179
3369
  * import { defineConfig } from 'astro/config';
3180
3370
  *
3181
3371
  * export default defineConfig({
@@ -3213,11 +3403,13 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
3213
3403
  *
3214
3404
  * ```js
3215
3405
  * // astro.config.mjs
3216
- * {
3406
+ * import { defineConfig } from 'astro/config';
3407
+ *
3408
+ * export default defineConfig({
3217
3409
  * experimental: {
3218
3410
  * incrementalBuild: true,
3219
3411
  * },
3220
- * }
3412
+ * });
3221
3413
  * ```
3222
3414
  *
3223
3415
  * In your dynamic routes, return a `cacheKey` from `getStaticPaths()`: