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.
272
+
Alternatively, you can use a custom server implementation that leverages Bun's native APIs.
273
273
274
-
We've created an optimized productionserver that provides intelligent static asset loading with configurable memory management.
274
+
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.
275
275
276
-
**Features:**
276
+
**This is a starting point - feel free to adapt it to your needs or simplify it for your use case.**
277
277
278
-
-**Hybrid loading strategy**: Small files (<5MB by default) are preloaded into memory, large files are served on-demand
279
-
-**Configurable file filtering**: Use include/exclude patterns to control which files are preloaded
280
-
-**Production-ready caching headers**: Automatic optimization for static assets
- Serving static assets using Bun's native file handling
281
+
- Hybrid loading strategy (preload small files, serve large files on-demand)
282
+
- Optional features like ETag support and Gzip compression
283
+
- Production-ready caching headers
282
284
283
285
**Quick Setup:**
284
286
285
-
1. Copy the [`server.ts`](https://github.com/tanstack/router/blob/main/examples/react/start-bun/server.ts) file from the example in this repository to your project root
287
+
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)
286
288
287
289
2. Build your application:
288
290
@@ -296,36 +298,57 @@ We've created an optimized production server that provides intelligent static as
296
298
bun run server.ts
297
299
```
298
300
299
-
**Configuration:**
301
+
**Configuration (Optional):**
300
302
301
-
The server can be configured using environment variables:
303
+
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:
302
304
303
305
```sh
304
-
# Basic usage
306
+
# Basic usage - just works out of the box
305
307
bun run server.ts
306
308
307
-
# Custom port
308
-
PORT=8080 bun run server.ts
309
+
# Common configurations
310
+
PORT=8080 bun run server.ts # Custom port
311
+
ASSET_PRELOAD_VERBOSE_LOGGING=true bun run server.ts # See what's happening
0 commit comments