1.1.6 • Published 6 months ago
@lazuee/react-router-hono v1.1.6
react-router-hono
react-router-honois a Vite plugin that integrateshonowithreact-router, providing presets to simplify production setups.
Installation
Install the package:
pnpm add -D @lazuee/react-router-honoUsage
Vite Configuration
Add the plugin to your vite.config.js:
import { env } from "node:process";
import { reactRouterHono } from "@lazuee/react-router-hono";
import { reactRouter } from "@react-router/dev/vite";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
const port = Number.parseInt(env?.PORT || "3000");
export default defineConfig({
plugins: [
reactRouterHono({
serverFile: "src/server/index.ts", // Path to your Hono server file
}),
reactRouter(),
tsconfigPaths(),
],
server: {
port, // This port will be used as the default unless overridden by `process.env.PORT` or `process.env.APP_PORT`
},
});Hono Configuration
Once you set the serverFile in the reactRouterHono plugin configuration, the file specified will be used as the base for your Hono server.
import { type ReactRouterHono } from "@lazuee/react-router-hono";
const reactRouterHono: ReactRouterHono = {
getLoadContext(ctx) {
return {
message: "hello from hono",
};
},
server(app) {
app.get("/ping", (c) => c.text("pong"));
},
};
export default reactRouterHono;For a usage example, check the website folder.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Copyright © 2024-2025 lazuee
1.1.6
6 months ago
1.1.5
7 months ago
1.1.4
8 months ago
1.1.3
9 months ago
1.1.2
9 months ago
1.1.1
10 months ago
1.1.0
11 months ago
1.0.9
11 months ago
1.0.8
11 months ago
1.0.7
11 months ago
1.0.6
11 months ago
1.0.5
11 months ago
1.0.4
11 months ago
1.0.3
12 months ago
1.0.2
12 months ago
1.0.1
12 months ago
1.0.0
12 months ago