Skip to content

Commit fbc8f42

Browse files
committed
update the migration guides to SolidStart v2
1 parent bc89abd commit fbc8f42

1 file changed

Lines changed: 52 additions & 58 deletions

File tree

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

Lines changed: 52 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tags:
99
- template
1010
- quickstart
1111
- init
12-
version: '2.0'
12+
version: "2.0"
1313
description: >-
1414
Migrate your SolidStart project from v1 to v2.
1515
---
@@ -20,87 +20,81 @@ 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, loadEnv } from "vite";
41+
import { nitroV2Plugin } from "@solidjs/vite-plugin-nitro-2";
42+
43+
export default defineConfig(({ mode }) => {
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+
});
6472

65-
```bash
66-
pnpm remove vinxi
6773
```
6874
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.
75+
Update the build/dev commands to use native Vite instead of vinxi.
7876
7977
```json
8078
"scripts": {
8179
"dev": "vite dev",
82-
"build": "vite build"
80+
"build": "vite build",
81+
"start": "vite preview"
8382
}
8483
```
8584
86-
**6. Replace all imports from `vinxi/http` with `@solidjs/start/http`**
8785
88-
**7. Add back nitro via the vite plugin**
86+
### Environment types
8987
90-
```package-install
91-
nitro@latest
88+
Only the `types` entry is new in v2. Everything else can remain unchanged.
89+
90+
```json
91+
"compilerOptions": {
92+
"types": ["@solidjs/start/env"]
93+
}
9294
```
9395
94-
```tsx
95-
import { defineConfig } from "vite";
96-
import { solidStart } from "@solidjs/start/config";
9796
98-
export default defineConfig({
99-
plugins: [
100-
solidStart(),
101-
nitro({
102-
preset: 'netlify'
103-
})
104-
]
105-
});
106-
```
97+
## Server runtime helpers
98+
99+
- Replace all imports from `vinxi/http` with `@solidjs/start/http`
100+
- Optional: update the middleware syntax to the newer [H3 syntax](https://h3.dev/guide/basics/middleware)

0 commit comments

Comments
 (0)