Skip to content

Commit 7216690

Browse files
update the migration guides to SolidStart v2 (#1435)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d31c94f commit 7216690

1 file changed

Lines changed: 52 additions & 57 deletions

File tree

src/routes/solid-start/migrating-from-v1.mdx

Lines changed: 52 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -20,87 +20,82 @@ Please note that some third-party packages may not be compatible with v2 yet.
2020

2121
## Migration steps
2222

23-
**1. Update your project to use the latest version of SolidStart**
23+
### Update dependencies
2424

2525
```package-install
26-
@solidjs/start@alpha
26+
@solidjs/start@alpha.2 @solidjs/vite-plugin-nitro-2 vite@7
2727
```
2828

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-
});
29+
```package-remove
30+
vinxi
4331
```
4432

45-
An important note is that `defineConfig` comes from `vite` directly.
33+
### Configuration files
4634

47-
#### Defining middleware
35+
- Remove `app.config.ts`
36+
- Create `vite.config.ts`
4837

49-
Middlware is defined using the `middleware` option on the `solidStart` vite plugin.
50-
51-
```tsx
52-
import { defineConfig } from "vite";
38+
```tsx title="vite.config.ts"
5339
import { solidStart } from "@solidjs/start/config";
54-
export default defineConfig({
55-
plugins: [
56-
solidStart({
57-
middleware: "./src/middleware.ts"
58-
}),
59-
]
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+
};
6052
});
6153
```
6254

63-
**4. Remove the vinxi dependency and add the vite dependency**
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+
});
6473

65-
```bash
66-
pnpm remove vinxi
6774
```
6875

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.
76+
Update the build/dev commands to use native Vite instead of vinxi.
7877

7978
```json
8079
"scripts": {
8180
"dev": "vite dev",
82-
"build": "vite build"
81+
"build": "vite build",
82+
"start": "vite preview"
8383
}
8484
```
8585

86-
**6. Replace all imports from `vinxi/http` with `@solidjs/start/http`**
8786

88-
**7. Add back nitro via the vite plugin**
87+
### Environment types
8988

90-
```package-install
91-
nitro@latest
89+
Only the `types` entry is new in v2. Everything else can remain unchanged.
90+
91+
```json
92+
"compilerOptions": {
93+
"types": ["@solidjs/start/env"]
94+
}
9295
```
9396

94-
```tsx
95-
import { defineConfig } from "vite";
96-
import { solidStart } from "@solidjs/start/config";
9797

98-
export default defineConfig({
99-
plugins: [
100-
solidStart(),
101-
nitro({
102-
preset: 'netlify'
103-
})
104-
]
105-
});
106-
```
98+
## Server runtime helpers
99+
100+
- Replace all imports from `vinxi/http` with `@solidjs/start/http`
101+
- Optional: update the middleware syntax to the newer [H3 syntax](https://h3.dev/guide/basics/middleware)

0 commit comments

Comments
 (0)