Files
Devour/devour_data/docs/define-config.json
T
Tomas Dvorak 898a3c303f update
2026-02-24 10:33:59 +01:00

17 lines
7.5 KiB
JSON

{
"id": "c2d0104c436868152a54c3c4",
"source": "solid:signals",
"type": "github-document",
"title": "define-config",
"content": "---\ntitle: defineConfig\nuse_cases: \u003e-\n app configuration, deployment setup, build optimization, platform targeting,\n vite plugins, nitro presets\ntags:\n - configuration\n - vite\n - nitro\n - deployment\n - build\n - plugins\nversion: '1.0'\ndescription: \u003e-\n Configure SolidStart apps with defineConfig. Set up Vite plugins, Nitro\n presets, and deployment targets for any platform.\n---\n\nThe `defineConfig` helper is from `@solidjs/start/config` and is used within [`app.config.ts`](/solid-start/reference/entrypoints/app-config).\n\nIt takes a configuration object with settings for SolidStart, Vite, and Nitro.\n\n## Configuring Vite\n\nSolidStart supports most Vite options, including plugins via the `vite` option:\n\n```tsx\nimport { defineConfig } from \"@solidjs/start/config\";\n\nexport default defineConfig({\n\tvite: {\n\t\t// vite options\n\t\tplugins: [],\n\t},\n});\n```\n\nThe `vite` option can also be a function that can be customized for each Vinxi router.\n\nIn SolidStart, 3 routers are used:\n- `server` - server-side routing\n- `client` - for the client-side routing\n- `server-function` - server functions.\n\n```tsx\nimport { defineConfig } from \"@solidjs/start/config\";\n\nexport default defineConfig({\n\tvite({ router }) {\n\t\tif (router === \"server\") {\n\t\t} else if (router === \"client\") {\n\t\t} else if (router === \"server-function\") {\n\t\t}\n\t\treturn { plugins: [] };\n\t},\n});\n```\n\n## Configuring Nitro\n\nSolidStart uses [Nitro](https://nitro.build/) to run on a number of platforms.\nThe `server` option exposes some Nitro options including the build and deployment presets.\nAn overview of all available presets is available in the [Deploy section of the Nitro documentation](https://nitro.build/deploy).\n\n Some common ones include:\n\n**Servers**\n\n- [Node.js Server](https://nitro.build/deploy/runtimes/node#handler-advanced) (`node`) (Default)\n- [Deno Server](https://nitro.build/deploy/runtimes/deno) (`deno_server`)\n- [Bun Server](https://nitro.build/deploy/runtimes/bun) (`bun`)\n\n**Providers**\n\n- [Netlify Functions and Edge](https://nitro.build/deploy/providers/netlify) (`netlify`, `netlify-edge`)\n- [Vercel Functions and Edge](https://nitro.build/deploy/providers/vercel) (`vercel`, `vercel-edge`)\n- [AWS Lambda and Lambda@Edge](https://nitro.build/deploy/providers/aws) (`aws_lambda`)\n- [Cloudflare Workers and Pages](https://nitro.build/deploy/providers/cloudflare) (`cloudflare`, `cloudflare_pages`, `cloudflare_module`)\n- [Deno Deploy](https://nitro.build/deploy/providers/deno-deploy) (`deno_deploy`)\n\n**Static site generation**\n\n- [Route pre-rendering](/solid-start/building-your-application/route-prerendering)\n\nBy passing no arguments, the default will be the Node preset.\nOther presets may be automatically detected by the provider, however, if not, they must be added to the configuration within the `server-preset` option.\n\nFor example, using Netlify Edge would look like the following:\n\n```tsx\nimport { defineConfig } from \"@solidjs/start/config\";\n\nexport default defineConfig({\n\tserver: {\n\t\tpreset: \"netlify_edge\",\n\t},\n});\n```\n\n#### Special note\n\nSolidStart uses async local storage.\nNetlify, Vercel, and Deno support this out of the box but if you're using Cloudflare you will need to specify the following:\n\n```js\nimport { defineConfig } from \"@solidjs/start/config\";\n\nexport default defineConfig({\n\tserver: {\n\t\tpreset: \"cloudflare_module\",\n\t\trollupConfig: {\n\t\t\texternal: [\"__STATIC_CONTENT_MANIFEST\", \"node:async_hooks\"],\n\t\t},\n\t},\n});\n```\n\nWithin `wrangler.toml` you will need to enable node compatibility:\n\n```\ncompatibility_flags = [ \"nodejs_compat\" ]\n```\n\n## Parameters\n\n| Property | Type | Default | Description |\n| -------------------- | ------------------------------------------ | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| ssr | boolean | true | Toggle between client and server rendering. |\n| solid | object | | Configuration object for [vite-plugin-solid](https://github.com/solidjs/vite-plugin-solid) |\n| extensions | string[] | [\"js\", \"jsx\", \"ts\", \"tsx\"] | Array of file extensions to be treated as routes. |\n| server | object | | Nitro server config options |\n| appRoot | string | \"./src\" | The path to the root of the application. |\n| routeDir | string | \"./routes\" | The path to where the routes are located. |\n| middleware | string | | The path to an optional [middleware](/solid-start/advanced/middleware) file. |\n| devOverlay | boolean | true | Toggle the dev overlay. |\n| experimental.islands | boolean | false | Enable \"islands\" mode. |\n| vite | `ViteConfig` or `({ router })=\u003eViteConfig` | | [Vite config object](https://vitejs.dev/config/shared-options.html). Can be configured for each `router` which has the string value \"server\", \"client\" or \"server-function\"` |",
"url": "https://github.com/solidjs/solid-docs/blob/HEAD/src/routes/solid-start/reference/config/define-config.mdx",
"metadata": {
"path": "src/routes/solid-start/reference/config/define-config.mdx",
"repo": "solidjs/solid-docs",
"repo_url": "https://github.com/solidjs/solid-docs.git",
"size": 6872,
"source_type": "github"
},
"hash": "441cdc4e00d7caaf10dabb24d48110d3c06c552fde541a8408253cdacfa83607",
"timestamp": "2026-02-23T11:43:00.194674398+01:00"
}