Skip to content

Commit 92280f4

Browse files
committed
Merge branch 'main' into #5171-consider-root-route
2 parents b530675 + 56f6f8d commit 92280f4

295 files changed

Lines changed: 23657 additions & 1108 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/router/framework/react/routing/installation-with-router-cli.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ To use file-based routing with the TanStack Router CLI, you'll need to install t
1111
npm install -D @tanstack/router-cli
1212
```
1313

14-
Once installed, you'll need to amend your your scripts in your `package.json` for the CLI to `watch` and `generate` files.
14+
Once installed, you'll need to amend your scripts in your `package.json` for the CLI to `watch` and `generate` files.
1515

1616
```json
1717
{

‎docs/start/framework/react/hosting.md‎

Lines changed: 91 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ import { cloudflare } from '@cloudflare/vite-plugin'
5353
import viteReact from '@vitejs/plugin-react'
5454

5555
export default defineConfig({
56-
plugins: [tanstackStart(), cloudflare(), viteReact()],
56+
plugins: [
57+
cloudflare({ viteEnvironment: { name: 'ssr' } }),
58+
tanstackStart(),
59+
viteReact(),
60+
],
5761
})
5862
```
5963

@@ -114,13 +118,15 @@ Deploy your application using their one-click deployment process, and you're rea
114118

115119
**⚠️ During TanStack Start 1.0 release candidate phase, we currently recommend using:**
116120

117-
- [@tanstack/tanstack-nitro-v2-vite-plugin (Temporary Compatibility Plugin)](https://www.npmjs.com/package/@tanstack/tanstack-nitro-v2-vite-plugin) - A temporary compatibility plugin for using Nitro v2 as the underlying build tool for TanStack Start.
118-
- [Nitro v3's Vite Plugin (BETA)](https://www.npmjs.com/package/nitro-vite) - A **BETA** plugin for officially using Nitro v3 as the underlying build tool for TanStack Start.
121+
- [@tanstack/nitro-v2-vite-plugin (Temporary Compatibility Plugin)](https://www.npmjs.com/package/@tanstack/nitro-v2-vite-plugin) - A temporary compatibility plugin for using Nitro v2 as the underlying build tool for TanStack Start.
122+
- [Nitro v3's Vite Plugin (BETA)](https://www.npmjs.com/package/nitro-nightly) - A **BETA** plugin for officially using Nitro v3 as the underlying build tool for TanStack Start.
119123

120124
#### Using Nitro v2
121125

122126
**⚠️ `@tanstack/nitro-v2-vite-plugin` is a temporary compatibility plugin for using Nitro v2 as the underlying build tool for TanStack Start. Use this plugin if you experience issues with the Nitro v3 plugin. It does not support all of Nitro v3's features and is limited in it's dev server capabilities, but should work as a safe fallback, even for production deployments for those who were using TanStack Start's alpha/beta versions.**
123127

128+
If you want to use this plugin with bun please make sure to use [isolated installs](https://bun.com/docs/install/isolated#using-isolated-installs).
129+
124130
```tsx
125131
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
126132
import { defineConfig } from 'vite'
@@ -132,15 +138,21 @@ export default defineConfig({
132138
plugins: [
133139
tsConfigPaths({ projects: ['./tsconfig.json'] }),
134140
tanstackStart(),
135-
nitro(),
141+
nitroV2Plugin(),
136142
viteReact(),
137143
],
138144
})
139145
```
140146

141147
#### Using Nitro v3 (BETA)
142148

143-
**⚠️ The `nitro/vite` plugin is an official **BETA** plugin from the Nitro team for using Nitro v3 as the underlying build tool for TanStack Start. It is still in development and is receiving regular updates.**
149+
**⚠️ The `nitro` vite plugin is an official **BETA** plugin from the Nitro team for using Nitro v3 as the underlying build tool for TanStack Start. It is still in development and is receiving regular updates.**
150+
151+
This package needs to be installed as follows:
152+
153+
```
154+
"nitro": "npm:nitro-nightly",
155+
```
144156

145157
```tsx
146158
import { tanstackStart } from '@tanstack/react-start/plugin/vite'
@@ -202,10 +214,10 @@ npm run start
202214
Make sure that your `react` and `react-dom` packages are set to version 19.0.0 or higher in your `package.json` file. If not, run the following command to upgrade the packages:
203215

204216
```sh
205-
npm install react@rc react-dom@rc
217+
bun install react@19 react-dom@19
206218
```
207219

208-
Ensure your `vite.config.ts` file is correct.
220+
Ensure your `vite.config.ts` file is correct:
209221

210222
```ts
211223
// vite.config.ts
@@ -218,14 +230,81 @@ export default defineConfig({
218230
})
219231
```
220232

221-
Then you can run the following command to build and start your application:
233+
#### Production Server with Bun
234+
235+
To run TanStack Start applications in production with Bun, you need a custom server implementation.
236+
237+
We've created an optimized production server that provides intelligent static asset loading with configurable memory management.
238+
239+
**Features:**
240+
241+
- **Hybrid loading strategy**: Small files (<5MB by default) are preloaded into memory, large files are served on-demand
242+
- **Configurable file filtering**: Use include/exclude patterns to control which files are preloaded
243+
- **Production-ready caching headers**: Automatic optimization for static assets
244+
- **Memory-efficient**: Smart memory management prevents excessive RAM usage
245+
246+
**Quick Setup:**
247+
248+
1. Copy the [`server.ts`](../../../../examples/react/start-bun/server.ts) file from the example in this repository to your project root
249+
250+
2. Build your application:
251+
252+
```sh
253+
bun run build
254+
```
255+
256+
3. Start the server:
257+
258+
```sh
259+
bun run server.ts
260+
```
261+
262+
**Configuration:**
263+
264+
The server can be configured using environment variables:
222265

223266
```sh
224-
bun run build
267+
# Basic usage
268+
bun run server.ts
269+
270+
# Custom port
271+
PORT=8080 bun run server.ts
272+
273+
# Optimize for minimal memory usage (1MB preload limit)
274+
STATIC_PRELOAD_MAX_BYTES=1048576 bun run server.ts
275+
276+
# Preload only critical assets
277+
STATIC_PRELOAD_INCLUDE="*.js,*.css" \
278+
STATIC_PRELOAD_EXCLUDE="*.map,vendor-*" \
279+
bun run server.ts
280+
281+
# Debug mode with verbose logging
282+
STATIC_PRELOAD_VERBOSE=true bun run server.ts
225283
```
226284

227-
You're now ready to deploy your application to a Bun server. You can start your application by running:
285+
**Environment Variables:**
228286

229-
```sh
230-
bun run .output/server/index.mjs
287+
- `PORT`: Server port (default: 3000)
288+
- `STATIC_PRELOAD_MAX_BYTES`: Maximum file size to preload in bytes (default: 5242880 = 5MB)
289+
- `STATIC_PRELOAD_INCLUDE`: Comma-separated glob patterns for files to include
290+
- `STATIC_PRELOAD_EXCLUDE`: Comma-separated glob patterns for files to exclude
291+
- `STATIC_PRELOAD_VERBOSE`: Enable detailed logging (set to "true")
292+
293+
**Example Output:**
294+
295+
```txt
296+
📦 Loading static assets from ./dist/client...
297+
Max preload size: 5.00 MB
298+
299+
📁 Preloaded into memory:
300+
/assets/index-a1b2c3d4.js 45.23 kB │ gzip: 15.83 kB
301+
/assets/index-e5f6g7h8.css 12.45 kB │ gzip: 4.36 kB
302+
303+
💾 Served on-demand:
304+
/assets/vendor-i9j0k1l2.js 245.67 kB │ gzip: 86.98 kB
305+
306+
✅ Preloaded 2 files (57.68 KB) into memory
307+
🚀 Server running at http://localhost:3000
231308
```
309+
310+
For a complete working example, check out the [TanStack Start + Bun example](../../../../examples/react/start-bun) in this repository.

‎e2e/react-router/basic-file-based-code-splitting/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
"@types/react": "^19.0.8",
3030
"@types/react-dom": "^19.0.3",
3131
"@vitejs/plugin-react": "^4.3.4",
32-
"vite": "^7.1.1"
32+
"vite": "^7.1.7"
3333
}
3434
}

‎e2e/react-router/basic-file-based/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
"@types/react-dom": "^19.0.3",
3131
"@vitejs/plugin-react": "^4.3.4",
3232
"combinate": "^1.1.11",
33-
"vite": "^7.1.1"
33+
"vite": "^7.1.7"
3434
}
3535
}

‎e2e/react-router/basic-react-query-file-based/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
"@types/react": "^19.0.8",
3131
"@types/react-dom": "^19.0.3",
3232
"@vitejs/plugin-react": "^4.3.4",
33-
"vite": "^7.1.1"
33+
"vite": "^7.1.7"
3434
}
3535
}

‎e2e/react-router/basic-react-query/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
"@types/react": "^19.0.8",
2929
"@types/react-dom": "^19.0.3",
3030
"@vitejs/plugin-react": "^4.3.4",
31-
"vite": "^7.1.1"
31+
"vite": "^7.1.7"
3232
}
3333
}

‎e2e/react-router/basic-scroll-restoration/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727
"@types/react": "^19.0.8",
2828
"@types/react-dom": "^19.0.3",
2929
"@vitejs/plugin-react": "^4.3.4",
30-
"vite": "^7.1.1"
30+
"vite": "^7.1.7"
3131
}
3232
}

‎e2e/react-router/basic-virtual-file-based/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
"@types/react": "^19.0.8",
3030
"@types/react-dom": "^19.0.3",
3131
"@vitejs/plugin-react": "^4.3.4",
32-
"vite": "^7.1.1"
32+
"vite": "^7.1.7"
3333
}
3434
}

‎e2e/react-router/basic-virtual-named-export-config-file-based/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
"@types/react": "^19.0.8",
3030
"@types/react-dom": "^19.0.3",
3131
"@vitejs/plugin-react": "^4.3.4",
32-
"vite": "^7.1.1"
32+
"vite": "^7.1.7"
3333
}
3434
}

‎e2e/react-router/basic/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626
"@types/react": "^19.0.8",
2727
"@types/react-dom": "^19.0.3",
2828
"@vitejs/plugin-react": "^4.3.4",
29-
"vite": "^7.1.1"
29+
"vite": "^7.1.7"
3030
}
3131
}

0 commit comments

Comments
 (0)