|
| 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 | +**1. Update your project to use the latest version of SolidStart** |
| 24 | + |
| 25 | +```package-install |
| 26 | +@solidjs/start@alpha |
| 27 | +``` |
| 28 | + |
| 29 | +**2. Rename `app.config.ts` to `vite.config.ts`** |
| 30 | + |
| 31 | +**3. Update`vite.config.ts`** |
| 32 | + |
| 33 | +v2 ships as a native vite plugin using the environment api instead of vinxi. |
| 34 | + |
| 35 | +```tsx |
| 36 | +import { defineConfig } from "vite"; |
| 37 | +import { solidStart } from "@solidjs/start/config"; |
| 38 | +export default defineConfig({ |
| 39 | + plugins: [ |
| 40 | + solidStart(), |
| 41 | + ] |
| 42 | +}); |
| 43 | +``` |
| 44 | + |
| 45 | +An important note is that `defineConfig` comes from `vite` directly. |
| 46 | + |
| 47 | +#### Defining middleware |
| 48 | + |
| 49 | +Middlware is defined using the `middleware` option on the `solidStart` vite plugin. |
| 50 | + |
| 51 | +```tsx |
| 52 | +import { defineConfig } from "vite"; |
| 53 | +import { solidStart } from "@solidjs/start/config"; |
| 54 | +export default defineConfig({ |
| 55 | + plugins: [ |
| 56 | + solidStart({ |
| 57 | + middleware: "./src/middleware.ts" |
| 58 | + }), |
| 59 | + ] |
| 60 | +}); |
| 61 | +``` |
| 62 | + |
| 63 | +**4. Remove the vinxi dependency and add the vite dependency** |
| 64 | + |
| 65 | +```bash |
| 66 | +pnpm remove vinxi |
| 67 | +``` |
| 68 | + |
| 69 | +```json |
| 70 | +"dependencies": { |
| 71 | + "vite": "^7" |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +**5. Update`package.json` build/dev commands** |
| 76 | + |
| 77 | +Update the build/dev commands to use native vite instead of vinxi. |
| 78 | + |
| 79 | +```json |
| 80 | +"scripts": { |
| 81 | + "dev": "vite dev", |
| 82 | + "build": "vite build" |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +**6. Replace all leftover vinxi imports** |
| 87 | + |
| 88 | +- `useSession` now comes from `@solidjs/start/server` instead of `vinxi/http |
| 89 | + |
| 90 | +**7. Add back nitro via the vite plugin** |
| 91 | + |
| 92 | +```package-install |
| 93 | +nitro@latest |
| 94 | +``` |
| 95 | + |
| 96 | +```tsx |
| 97 | +import { defineConfig } from "vite"; |
| 98 | +import { solidStart } from "@solidjs/start/config"; |
| 99 | + |
| 100 | +export default defineConfig({ |
| 101 | + plugins: [ |
| 102 | + solidStart(), |
| 103 | + nitro({ |
| 104 | + preset: 'netlify' |
| 105 | + }) |
| 106 | + ] |
| 107 | +}); |
| 108 | +``` |
0 commit comments