Creating a Server
UsecreateHonoNodeServer to set up a Node.js HTTP server:
server.ts
Server Options
ThecreateHonoNodeServer function accepts comprehensive configuration options:
Port
Specify the server port:Logger
Control the default HTTP request logger:Configure Hook
Customize the Hono application before it starts handling requests:Load Context
Provide custom context to React Router loaders and actions:Shutdown Hook
Perform cleanup when the server shuts down:SIGINT and SIGTERM signals.
Middlewares
Resolid provides middleware utilities for common server concerns.Request ID
Generate unique identifiers for each request:Custom Generator
Provide a custom ID generator:Request Origin
Capture the request origin URL:Proxy Support
Enable proxy detection for origin resolution:X-Forwarded-Host and X-Forwarded-Proto headers when behind a proxy.
Client IP
Extract the client’s IP address:Custom IP Resolution
Configure IP resolution options:Static Files
Resolid automatically serves static files in production:Cache Control
Use thecacheControl middleware to set caching headers:
- Only applies to file requests (URLs with extensions)
- Skips
.datafiles (React Router data requests) - Sets
Cache-Controlwithpublicand optionalimmutable
Platform Adapters
Resolid provides adapters for different deployment platforms.Vercel
Netlify
Complete Example
Here’s a comprehensive server setup:server.ts