SolidStart
Archil.Website.SolidStart deploys a SolidStart app to an Archil
sandbox, with nitro’s node preset appended to your vite build; client assets and prerendered pages are served first. The site is the
program of its own sandbox, on port 3000, at a public
https://3000-…archil.app URL. A stopped sandbox starts again on the next
request.
Install
Section titled “Install”The build integration is not bundled with alchemy. Install
@alchemy.run/frontend-frameworks; the resource loads its
/solidstart and /solidstart/node exports from your project at
deploy time. It is only used at build time, so a dev dependency is
enough:
pnpm add -D https://pkg.alchemy.run/@alchemy.run/frontend-frameworks/pr:2930:0cabab6bun add -d https://pkg.alchemy.run/@alchemy.run/frontend-frameworks/pr:2930:0cabab6npm install -D https://pkg.alchemy.run/@alchemy.run/frontend-frameworks/pr:2930:0cabab6yarn add -D https://pkg.alchemy.run/@alchemy.run/frontend-frameworks/pr:2930:0cabab6@solidjs/vite-plugin-nitro-2 is the server half of a SolidStart
build and must be a project dependency too:
pnpm add @solidjs/vite-plugin-nitro-2bun add @solidjs/vite-plugin-nitro-2npm install @solidjs/vite-plugin-nitro-2yarn add @solidjs/vite-plugin-nitro-2Configure Vite
Section titled “Configure Vite”Your vite.config.ts is the SolidStart plugin — no adapter, no
nitro wiring. Vite plugins like Tailwind go in plugins as usual:
import { solidStart } from "@solidjs/start/config";import tailwindcss from "@tailwindcss/vite";import { defineConfig } from "vite";
export default defineConfig({ plugins: [solidStart(), tailwindcss()],});Alchemy appends its own nitroV2Plugin() instance at build time,
carrying nitro’s node preset. Don’t register nitroV2Plugin()
yourself — the appended instance would discard its options, so the
build fails with an actionable error instead. Pass nitro options
through the resource’s nitro prop; see Prerendering
below.
Declare the Website
Section titled “Declare the Website”Declare the site as a module-level const:
import * as Archil from "@alchemy.run/archil";
export const Website = Archil.Website.SolidStart("Website");sandbox sizes the site’s sandbox and sets its image, timeouts, disks and network policy:
export const Website = Archil.Website.SolidStart("Website", { sandbox: { vcpuCount: 2, memSizeMiB: 4096, idleTtlSeconds: 600 },});Add it to the Stack
Section titled “Add it to the Stack”Yield the site from your Stack and return its URL:
import * as Archil from "@alchemy.run/archil";import * as Alchemy from "alchemy";import * as Effect from "effect/Effect";
export const Website = Archil.Website.SolidStart("Website");
export default Alchemy.Stack( "MySolidStartSite", { providers: Archil.providers(), state: Alchemy.localState(), }, Effect.gen(function* () { const site = yield* Website; return { url: site.url }; }),);Run alchemy deploy. url is the site’s https://3000-…archil.app URL.
site.sandbox is the sandbox behind it, and undefined under
alchemy dev.
See examples/archil-website-solidstart for the checked-in example.
Add environment variables
Section titled “Add environment variables”Process environment is a top-level env map — plain strings, or
Redacted values:
export const Website = Archil.Website.SolidStart("Website", { env: { API_BASE: "https://api.example.com", },});The values are copied onto process.env before the build and the
dev server, and onto the program at deploy time, so server
code reads the same keys in both modes. Client inlining is whatever
Vite does (VITE_ prefixes).
An output from another resource only exists once that resource is yielded, so declare the site inside the Stack generator instead:
Effect.gen(function* () { const api = yield* Api;
const site = yield* Archil.Website.SolidStart("Website", { env: { API_BASE: api.url }, });
return { url: site.url };});Read the environment in server code
Section titled “Read the environment in server code”The SolidStart server is a plain Node process, so API routes,
server functions, and SSR read the environment from process.env:
export function GET() { return new Response(process.env.API_BASE ?? "unset");}Values prefixed VITE_ are inlined into the client bundle at build
time instead, as import.meta.env.VITE_* — set those in the shell
that runs alchemy deploy, not in env.
Prerendering
Section titled “Prerendering”Nitro renders the routes you list at build time into .output/public.
They are uploaded with the program and served as static files with no
handler invocation:
export const Website = Archil.Website.SolidStart("Website", { nitro: { prerender: { routes: ["/", "/about"] } },});prerender takes the routes to render (routes) and can crawl links
from prerendered pages to prerender them too (crawlLinks). The
nitro prop is the home for all nitro options (route rules, storage,
…) — the integration owns the plugin instance, so they cannot live
in vite.config.ts. Values must be JSON-serializable; preset is
owned by the Node deploy target, and a foreign preset is a hard error.
Local dev
Section titled “Local dev”bun alchemy devalchemy dev runs SolidStart’s own Vite dev server (native HMR)
instead of deploying; site.url is the local address and no Archil
resources are created. Nitro plays no part in dev. Wrap the site in
Alchemy.remote() to deploy the live sandbox even during
dev:
export const Website = Archil.Website.SolidStart("Website").pipe( Alchemy.remote(),);SolidStart’s plugin resolves its app root and route directory from
the process working directory, so one alchemy dev process serves
one SolidStart app at a time.
Where next
Section titled “Where next”Archil.Website.SolidStartreference- Websites — every framework Archil hosts
- Programs and Sandboxes — what the site runs on