The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | --- |
| 2 | title: SolidStart |
| 3 | description: Deploy SolidStart to Prisma Compute with Prisma.Website.SolidStart — Nitro's Node target on Bun and SolidStart's native Vite dev server locally. |
| 4 | sidebar: |
| 5 | order: 10.5 |
| 6 | --- |
| 7 | |
| 8 | import PackageManagers from "../../../../components/PackageManagers.astro"; |
| 9 | |
| 10 | export const devDeps = "@alchemy.run/frontend-frameworks @vercel/nft"; |
| 11 | |
| 12 | `Prisma.Website.SolidStart` runs your [SolidStart](https://start.solidjs.com) |
| 13 | project's Vite build with Nitro's Node preset. SSR, client assets, and |
| 14 | prerendered pages run on **Bun in Prisma Compute** from a `tar.gz` |
| 15 | artifact, not a Docker image. |
| 16 | |
| 17 | :::note[Version line] |
| 18 | This integration targets `@solidjs/start` 2.x with |
| 19 | `@solidjs/vite-plugin-nitro-2`: `solidStart()` is a Vite plugin, and |
| 20 | Nitro is a second plugin managed by Alchemy. |
| 21 | ::: |
| 22 | |
| 23 | ## Install |
| 24 | |
| 25 | Install the build integration; the resource loads `/solidstart` and |
| 26 | `/solidstart/node` from your project: |
| 27 | |
| 28 | <PackageManagers dev={devDeps} /> |
| 29 | |
| 30 | Install the Nitro plugin dependency too: |
| 31 | |
| 32 | <PackageManagers add="@solidjs/vite-plugin-nitro-2" /> |
| 33 | |
| 34 | ## Configure Vite |
| 35 | |
| 36 | ```typescript |
| 37 | // vite.config.ts |
| 38 | import { solidStart } from "@solidjs/start/config"; |
| 39 | import tailwindcss from "@tailwindcss/vite"; |
| 40 | import { defineConfig } from "vite"; |
| 41 | |
| 42 | export default defineConfig({ |
| 43 | plugins: [solidStart(), tailwindcss()], |
| 44 | }); |
| 45 | ``` |
| 46 | |
| 47 | Alchemy appends `nitroV2Plugin()` with its Node preset at build time. |
| 48 | Don't register another Nitro plugin yourself: conflicting instances |
| 49 | fail the build. Put Nitro overrides in the resource's `nitro` bag. |
| 50 | |
| 51 | ## Declare the Website |
| 52 | |
| 53 | ```typescript |
| 54 | // alchemy.run.ts |
| 55 | import * as Prisma from "@alchemy.run/prisma"; |
| 56 | |
| 57 | export const Website = Prisma.Website.SolidStart("Website", { |
| 58 | rootDir: "./app", |
| 59 | }); |
| 60 | ``` |
| 61 | |
| 62 | Omit `rootDir` for an app at `.`. Pass `project` to share an existing |
| 63 | project; otherwise live deploy creates a database-less Prisma project. |
| 64 | |
| 65 | ## Add it to the Stack |
| 66 | |
| 67 | ```typescript |
| 68 | // alchemy.run.ts |
| 69 | import * as Alchemy from "alchemy"; |
| 70 | import * as Effect from "effect/Effect"; |
| 71 | |
| 72 | export default Alchemy.Stack( |
| 73 | "MySolidStartSite", |
| 74 | { providers: Prisma.providers(), state: Alchemy.localState() }, |
| 75 | Effect.gen(function* () { |
| 76 | const site = yield* Website; |
| 77 | return { url: site.url }; |
| 78 | }), |
| 79 | ); |
| 80 | ``` |
| 81 | |
| 82 | `site.url` is the Compute endpoint on deploy and the local address in dev. |
| 83 | |
| 84 | ## Add environment variables |
| 85 | |
| 86 | ```diff lang="typescript" |
| 87 | export const Website = Prisma.Website.SolidStart("Website", { |
| 88 | rootDir: "./app", |
| 89 | + env: { API_BASE: "https://api.example.com" }, |
| 90 | }); |
| 91 | ``` |
| 92 | |
| 93 | Values are applied before build and dev and passed to Compute. Vite |
| 94 | inlines `VITE_*` keys into the client bundle; keep secrets out of them. |
| 95 | Sibling resource outputs can feed `env` inside the Stack generator. |
| 96 | |
| 97 | ## Read the environment in server code |
| 98 | |
| 99 | ```typescript |
| 100 | // src/routes/api/hello.ts |
| 101 | export function GET() { |
| 102 | return new Response(process.env.API_BASE ?? "unset"); |
| 103 | } |
| 104 | ``` |
| 105 | |
| 106 | API routes, server functions, and SSR run on Bun and read `process.env`. |
| 107 | |
| 108 | ## Prerendering |
| 109 | |
| 110 | ```typescript |
| 111 | export const Website = Prisma.Website.SolidStart("Website", { |
| 112 | nitro: { prerender: { routes: ["/", "/about"] } }, |
| 113 | }); |
| 114 | ``` |
| 115 | |
| 116 | Nitro emits those pages into `.output/public`; Compute serves them as |
| 117 | files without invoking SSR. `crawlLinks` can discover more routes. |
| 118 | The `nitro` bag accepts serializable options such as route rules and |
| 119 | storage, but the Node target owns `preset`. |
| 120 | |
| 121 | ## Local dev |
| 122 | |
| 123 | `alchemy dev` runs SolidStart's Vite server with HMR; Nitro is not part |
| 124 | of the dev path and the Website creates no Prisma resources. SolidStart |
| 125 | resolves the app root from the working directory, so run one SolidStart |
| 126 | app per dev process. |
| 127 | |
| 128 | :::caution[Run SolidStart dev under Node] |
| 129 | The SolidStart 2 dev server's `srvx/node` path can return |
| 130 | `[object Object]` under Bun. Use `npx alchemy dev` for the dev server. |
| 131 | This is a local dev-server limitation, not a change to Prisma's |
| 132 | production runtime: the deployed Node-target build runs on Bun. |
| 133 | ::: |
| 134 | |
| 135 | Opt into the live deployment during dev explicitly: |
| 136 | |
| 137 | ```typescript |
| 138 | export const Website = Prisma.Website.SolidStart("Website").pipe( |
| 139 | Alchemy.remote(), |
| 140 | ); |
| 141 | ``` |
| 142 | |
| 143 | ## Custom domain |
| 144 | |
| 145 | ```typescript |
| 146 | const site = yield* Prisma.Website.SolidStart("Web", { |
| 147 | domain: "app.example.com", |
| 148 | }); |
| 149 | ``` |
| 150 | |
| 151 | `Prisma.CustomDomain` requires the app to be on the current default |
| 152 | branch. Configure returned DNS records yourself and verify status before |
| 153 | cutover; see [Custom domains](/prisma/frontend/websites#custom-domains). |
| 154 | |
| 155 | ## Where next |
| 156 | |
| 157 | - [SolidStart API](/providers/prisma/website/solidstart). |
| 158 | - [SolidStart example](https://github.com/alchemy-run/alchemy/tree/main/examples/prisma-website-solidstart). |
| 159 | - [Websites](/prisma/frontend/websites) and [Compute apps](/prisma/compute/apps). |