Config

defineConfig

Edit this page

The defineConfig helper is from @solidjs/start/config and is used within app.config.ts.

It takes a configuration object with settings for SolidStart, Vite, and Nitro.


Configuring Vite

SolidStart supports most Vite options, including plugins via the vite option:

import { defineConfig } from "@solidjs/start/config";
export default defineConfig({
vite: {
// vite options
plugins: [],
},
});

The vite option can also be a function that can be customized for each Vinxi router.

In SolidStart, 3 routers are used:

  • server - server-side routing
  • client - for the client-side routing
  • server-function - server functions.
import { defineConfig } from "@solidjs/start/config";
export default defineConfig({
vite({ router }) {
if (router === "server") {
} else if (router === "client") {
} else if (router === "server-function") {
}
return { plugins: [] };
},
});

Serialization

SolidStart serializes server function payloads so they can move between server and client. You can configure the serializer mode to balance performance, payload size, and Content Security Policy (CSP) constraints.

import { defineConfig } from "@solidjs/start/config";
export default defineConfig({
serialization: {
mode: "json",
},
});

Modes

  • json: Uses JSON.parse on the client. This is the safest option for strict CSP because it avoids eval. Payloads can be slightly larger.
  • js: Uses Seroval's JS serializer for smaller payloads and better performance, but it relies on eval during client-side deserialization and requires unsafe-eval in CSP.

Defaults

  • SolidStart v1 defaults to js for backwards compatibility.
  • SolidStart v2 defaults to json for CSP compatibility.

Supported types (default)

SolidStart enables Seroval plus a default set of web platform plugins. These plugins add support for:

  • AbortSignal, CustomEvent, DOMException, Event
  • FormData, Headers, ReadableStream
  • Request, Response
  • URL, URLSearchParams

Seroval supports additional value types. The compatibility list is broader than what SolidStart enables by default, so treat it as a superset. See the full list in the Seroval compatibility docs.


Configuring Nitro

SolidStart uses Nitro to run on a number of platforms. The server option exposes some Nitro options including the build and deployment presets. An overview of all available presets is available in the Deploy section of the Nitro documentation.

Some common ones include:

Servers

Providers

Static site generation

By passing no arguments, the default will be the Node preset. Other presets may be automatically detected by the provider, however, if not, they must be added to the configuration within the server-preset option.

For example, using Netlify Edge would look like the following:

import { defineConfig } from "@solidjs/start/config";
export default defineConfig({
server: {
preset: "netlify_edge",
},
});

Special note

SolidStart uses async local storage. Netlify, Vercel, and Deno support this out of the box but if you're using Cloudflare you will need to specify the following:

import { defineConfig } from "@solidjs/start/config";
export default defineConfig({
server: {
preset: "cloudflare_module",
rollupConfig: {
external: ["__STATIC_CONTENT_MANIFEST", "node:async_hooks"],
},
},
});

Within wrangler.toml you will need to enable node compatibility:

compatibility_flags = [ "nodejs_compat" ]

Parameters

PropertyTypeDefaultDescription
ssrbooleantrueToggle between client and server rendering.
solidobjectConfiguration object for vite-plugin-solid
extensionsstring[]["js", "jsx", "ts", "tsx"]Array of file extensions to be treated as routes.
serverobjectNitro server config options
serializationobjectSerialization settings for server function payloads.
appRootstring"./src"The path to the root of the application.
routeDirstring"./routes"The path to where the routes are located.
middlewarestringThe path to an optional middleware file.
devOverlaybooleantrueToggle the dev overlay.
experimental.islandsbooleanfalseEnable "islands" mode.
viteViteConfig or ({ router })=>ViteConfigVite config object. Can be configured for each router which has the string value "server", "client" or "server-function"`
Report an issue with this page