You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alternatively, you can use a custom server implementation that leverages Bun's native APIs.
295
+
296
+
We provide a reference implementation that demonstrates one approach to building a production-ready Bun server. This example uses Bun-native functions for optimal performance and includes features like intelligent asset preloading and memory management.
297
+
298
+
**This is a starting point - feel free to adapt it to your needs or simplify it for your use case.**
299
+
300
+
**What this example demonstrates:**
301
+
302
+
- Serving static assets using Bun's native file handling
303
+
- Hybrid loading strategy (preload small files, serve large files on-demand)
304
+
- Optional features like ETag support and Gzip compression
305
+
- Production-ready caching headers
306
+
307
+
**Quick Setup:**
308
+
309
+
1. Copy the [`server.ts`](https://github.com/tanstack/router/blob/main/examples/react/start-bun/server.ts) file from the example repository to your project root (or use it as inspiration for your own implementation)
310
+
311
+
2. Build your application:
312
+
313
+
```sh
314
+
bun run build
315
+
```
316
+
317
+
3. Start the server:
318
+
319
+
```sh
320
+
bun run server.ts
321
+
```
322
+
323
+
**Configuration (Optional):**
324
+
325
+
The reference server implementation includes several optional configuration options via environment variables. You can use these as-is, modify them, or remove features you don't need:
326
+
327
+
```sh
328
+
# Basic usage - just works out of the box
329
+
bun run server.ts
330
+
331
+
# Common configurations
332
+
PORT=8080 bun run server.ts # Custom port
333
+
ASSET_PRELOAD_VERBOSE_LOGGING=true bun run server.ts # See what's happening
For a complete working example, check out the [TanStack Start + Bun example](https://github.com/TanStack/router/tree/main/examples/react/start-bun) in this repository.
393
+
292
394
### Appwrite Sites
293
395
294
396
When deploying to [Appwrite Sites](https://appwrite.io/products/sites), you'll need to complete a few steps:
0 commit comments