|
| 1 | +--- |
| 2 | +title: Migrating from v1 |
| 3 | +use_cases: >- |
| 4 | + existing project, migration, upgrade |
| 5 | +tags: |
| 6 | + - setup |
| 7 | + - installation |
| 8 | + - starter |
| 9 | + - template |
| 10 | + - quickstart |
| 11 | + - init |
| 12 | +version: "2.0" |
| 13 | +description: >- |
| 14 | + Migrate your SolidStart project from v1 to v2. |
| 15 | +--- |
| 16 | + |
| 17 | +This is a migration guide of how to upgrade your v1 SolidStart app to our new v2 version. |
| 18 | + |
| 19 | +Please note that some third-party packages may not be compatible with v2 yet. |
| 20 | + |
| 21 | +## Migration steps |
| 22 | + |
| 23 | +### Update dependencies |
| 24 | + |
| 25 | +```package-install |
| 26 | +@solidjs/start@2.0.0-alpha.2 @solidjs/vite-plugin-nitro-2 vite@7 |
| 27 | +``` |
| 28 | + |
| 29 | +```package-remove |
| 30 | +vinxi |
| 31 | +``` |
| 32 | + |
| 33 | +### Configuration files |
| 34 | + |
| 35 | +- Remove `app.config.ts` |
| 36 | +- Create `vite.config.ts` |
| 37 | + |
| 38 | +```tsx title="vite.config.ts" |
| 39 | +import { solidStart } from "@solidjs/start/config"; |
| 40 | +import { defineConfig } from "vite"; |
| 41 | +import { nitroV2Plugin } from "@solidjs/vite-plugin-nitro-2"; |
| 42 | + |
| 43 | +export default defineConfig(() => { |
| 44 | + return { |
| 45 | + plugins: [ |
| 46 | + solidStart({ |
| 47 | + middleware: "./src/middleware/index.ts", |
| 48 | + }), |
| 49 | + nitroV2Plugin(), |
| 50 | + ], |
| 51 | + }; |
| 52 | +}); |
| 53 | +``` |
| 54 | + |
| 55 | +Compile-time environment variables are now handled by Vite's environment API. |
| 56 | + |
| 57 | +```tsx title="vite.config.ts" |
| 58 | +// ... |
| 59 | +export default defineConfig(({ mode }) => { |
| 60 | + const env = loadEnv(mode, process.cwd(), ""); |
| 61 | + |
| 62 | + return { |
| 63 | + // ... |
| 64 | + environments: { |
| 65 | + ssr: { |
| 66 | + define: { |
| 67 | + "process.env.DATABASE_URL": JSON.stringify(env.DATABASE_URL), |
| 68 | + }, |
| 69 | + }, |
| 70 | + }, |
| 71 | + }; |
| 72 | +}); |
| 73 | +``` |
| 74 | + |
| 75 | +Update the build/dev commands to use native Vite instead of vinxi. |
| 76 | + |
| 77 | +```json |
| 78 | +"scripts": { |
| 79 | + "dev": "vite dev", |
| 80 | + "build": "vite build", |
| 81 | + "start": "vite preview" |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +### Environment types |
| 86 | + |
| 87 | +Only the `types` entry is new in v2. Everything else can remain unchanged. |
| 88 | + |
| 89 | +```json |
| 90 | +"compilerOptions": { |
| 91 | + "types": ["@solidjs/start/env"] |
| 92 | +} |
| 93 | +``` |
| 94 | + |
| 95 | +## Server runtime helpers |
| 96 | + |
| 97 | +- Replace all imports from `vinxi/http` with `@solidjs/start/http` |
| 98 | +- Optional: update the middleware syntax to the newer [H3 syntax](https://h3.dev/guide/basics/middleware) |
0 commit comments