react-router-hono-server 2.19.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -1
- package/dist/adapters/aws-lambda.d.ts +2 -2
- package/dist/adapters/bun.d.ts +2 -2
- package/dist/adapters/cloudflare.d.ts +2 -2
- package/dist/adapters/node.d.ts +2 -2
- package/dist/dev.js +8 -10
- package/dist/{helpers-BKrW-3-B.d.ts → helpers-BcJiNpMs.d.ts} +2 -2
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -823,7 +823,35 @@ You can use React Router middleware with this package.
|
|
|
823
823
|
> [!IMPORTANT]
|
|
824
824
|
> Please note that this is an unstable feature and could change in the future.
|
|
825
825
|
>
|
|
826
|
-
> If you already have a custom `getLoadContext` function, you now have to return
|
|
826
|
+
> If you already have a custom `getLoadContext` function, you now have to return an instance of `unstable_RouterContextProvider` from it. Check this [example](./examples/node/simple-future-middleware/) for more information.
|
|
827
|
+
>
|
|
828
|
+
> ```ts
|
|
829
|
+
> import { unstable_RouterContextProvider, unstable_createContext } from "react-router";
|
|
830
|
+
> import { createHonoServer } from "react-router-hono-server/node";
|
|
831
|
+
>
|
|
832
|
+
> console.log("loading server");
|
|
833
|
+
>
|
|
834
|
+
> type GlobalAppContext = {
|
|
835
|
+
> appVersion: string;
|
|
836
|
+
> };
|
|
837
|
+
>
|
|
838
|
+
> export const globalAppContext = unstable_createContext<GlobalAppContext>();
|
|
839
|
+
>
|
|
840
|
+
> export default await createHonoServer({
|
|
841
|
+
> getLoadContext(_c, { mode, build }) {
|
|
842
|
+
> const isProductionMode = mode === "production";
|
|
843
|
+
> const context = new unstable_RouterContextProvider();
|
|
844
|
+
>
|
|
845
|
+
> context.set(globalAppContext, { appVersion: isProductionMode ? build.assets.version : "dev" });
|
|
846
|
+
>
|
|
847
|
+
> return context;
|
|
848
|
+
> },
|
|
849
|
+
> });
|
|
850
|
+
>```
|
|
851
|
+
|
|
852
|
+
Then, you can use the `use` function from `react-router` to access the context in your loaders and actions.
|
|
853
|
+
|
|
854
|
+
```ts
|
|
827
855
|
|
|
828
856
|
|
|
829
857
|
### Using WebSockets
|
|
@@ -2,8 +2,8 @@ import * as hono_aws_lambda from 'hono/aws-lambda';
|
|
|
2
2
|
import * as hono_types from 'hono/types';
|
|
3
3
|
import { BlankEnv } from 'hono/types';
|
|
4
4
|
import { Env, Hono } from 'hono';
|
|
5
|
-
import { H as HonoServerOptionsBase, W as WithoutWebsocket } from '../helpers-
|
|
6
|
-
export { c as createGetLoadContext } from '../helpers-
|
|
5
|
+
import { H as HonoServerOptionsBase, W as WithoutWebsocket } from '../helpers-BcJiNpMs.js';
|
|
6
|
+
export { c as createGetLoadContext } from '../helpers-BcJiNpMs.js';
|
|
7
7
|
import 'hono/ws';
|
|
8
8
|
import 'react-router';
|
|
9
9
|
|
package/dist/adapters/bun.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { Serve, ServeOptions } from 'bun';
|
|
|
2
2
|
import { Env } from 'hono';
|
|
3
3
|
import { ServeStaticOptions } from 'hono/serve-static';
|
|
4
4
|
import { BlankEnv } from 'hono/types';
|
|
5
|
-
import { H as HonoServerOptionsBase, a as WithWebsocket, W as WithoutWebsocket } from '../helpers-
|
|
6
|
-
export { c as createGetLoadContext } from '../helpers-
|
|
5
|
+
import { H as HonoServerOptionsBase, a as WithWebsocket, W as WithoutWebsocket } from '../helpers-BcJiNpMs.js';
|
|
6
|
+
export { c as createGetLoadContext } from '../helpers-BcJiNpMs.js';
|
|
7
7
|
import 'hono/ws';
|
|
8
8
|
import 'react-router';
|
|
9
9
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as hono_types from 'hono/types';
|
|
2
2
|
import { BlankEnv } from 'hono/types';
|
|
3
3
|
import { Env, Hono } from 'hono';
|
|
4
|
-
import { H as HonoServerOptionsBase, W as WithoutWebsocket } from '../helpers-
|
|
5
|
-
export { c as createGetLoadContext } from '../helpers-
|
|
4
|
+
import { H as HonoServerOptionsBase, W as WithoutWebsocket } from '../helpers-BcJiNpMs.js';
|
|
5
|
+
export { c as createGetLoadContext } from '../helpers-BcJiNpMs.js';
|
|
6
6
|
import 'hono/ws';
|
|
7
7
|
import 'react-router';
|
|
8
8
|
|
package/dist/adapters/node.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { ServerType } from '@hono/node-server';
|
|
|
3
3
|
import { ServeStaticOptions } from '@hono/node-server/serve-static';
|
|
4
4
|
import { Env, Hono } from 'hono';
|
|
5
5
|
import { BlankEnv } from 'hono/types';
|
|
6
|
-
import { H as HonoServerOptionsBase, a as WithWebsocket, W as WithoutWebsocket } from '../helpers-
|
|
7
|
-
export { c as createGetLoadContext } from '../helpers-
|
|
6
|
+
import { H as HonoServerOptionsBase, a as WithWebsocket, W as WithoutWebsocket } from '../helpers-BcJiNpMs.js';
|
|
7
|
+
export { c as createGetLoadContext } from '../helpers-BcJiNpMs.js';
|
|
8
8
|
import { ServerOptions, createServer } from 'node:http';
|
|
9
9
|
import { ServerOptions as ServerOptions$2, createServer as createServer$2, SecureServerOptions, createSecureServer } from 'node:http2';
|
|
10
10
|
import { ServerOptions as ServerOptions$1, createServer as createServer$1 } from 'node:https';
|
package/dist/dev.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from "path";
|
|
|
4
4
|
import honoDevServer from "@hono/vite-dev-server";
|
|
5
5
|
import bunAdapter from "@hono/vite-dev-server/bun";
|
|
6
6
|
import nodeAdapter from "@hono/vite-dev-server/node";
|
|
7
|
-
var
|
|
7
|
+
var REACT_ROUTER_SERVER_BUILD_MODULE_ID = "\0virtual:react-router/server-build";
|
|
8
8
|
var VIRTUAL_MODULE_ID = "\0virtual:react-router-hono-server/server";
|
|
9
9
|
var REACT_ROUTER_EXPORT = "export { serverManifest as assets, assetsBuildDirectory, basename, entry, future, isSpaMode, prerender, publicPath, routes, ssr, routeDiscovery };";
|
|
10
10
|
function reactRouterHonoServer(options = {}) {
|
|
@@ -34,6 +34,7 @@ function reactRouterHonoServer(options = {}) {
|
|
|
34
34
|
if (!pluginConfig) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
+
const serverEntryPoint = pluginConfig.serverEntryPoint;
|
|
37
38
|
if (pluginConfig.future.unstable_viteEnvironmentApi) {
|
|
38
39
|
console.warn(
|
|
39
40
|
"\x1B[33mThe unstable_viteEnvironmentApi is enabled.\nThis is experimental and may break your build.\x1B[0m\n"
|
|
@@ -92,10 +93,10 @@ Please add it to your plugins: import { cloudflareDevProxy } from "@react-router
|
|
|
92
93
|
},
|
|
93
94
|
build: {
|
|
94
95
|
rollupOptions: {
|
|
95
|
-
input:
|
|
96
|
+
input: serverEntryPoint,
|
|
96
97
|
output: {
|
|
97
98
|
entryFileNames: (chunk) => {
|
|
98
|
-
chunk.facadeModuleId =
|
|
99
|
+
chunk.facadeModuleId = REACT_ROUTER_SERVER_BUILD_MODULE_ID;
|
|
99
100
|
return "index.js";
|
|
100
101
|
},
|
|
101
102
|
// not invoked when target is webworker (single file output)
|
|
@@ -105,14 +106,11 @@ Please add it to your plugins: import { cloudflareDevProxy } from "@react-router
|
|
|
105
106
|
}
|
|
106
107
|
return "assets/[name]-[hash].js";
|
|
107
108
|
},
|
|
108
|
-
manualChunks: runtime !== "cloudflare" ? (id) => {
|
|
109
|
-
if (id.includes(
|
|
110
|
-
return
|
|
109
|
+
manualChunks: runtime !== "cloudflare" ? (id, meta) => {
|
|
110
|
+
if (meta.getModuleInfo(id)?.importers.some((id2) => id2.includes(serverEntryPoint))) {
|
|
111
|
+
return path.basename(id, path.extname(id));
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
-
return "server";
|
|
114
|
-
}
|
|
115
|
-
return "chunk";
|
|
113
|
+
return void 0;
|
|
116
114
|
} : void 0,
|
|
117
115
|
// We are doing that because we build a single file that only exports the Hono server
|
|
118
116
|
// RR needs its exports for prerendering
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as hono from 'hono';
|
|
2
2
|
import { Env, Hono, Context } from 'hono';
|
|
3
3
|
import { UpgradeWebSocket } from 'hono/ws';
|
|
4
|
-
import { ServerBuild, UNSAFE_MiddlewareEnabled,
|
|
4
|
+
import { ServerBuild, UNSAFE_MiddlewareEnabled, unstable_RouterContextProvider, AppLoadContext } from 'react-router';
|
|
5
5
|
|
|
6
6
|
type ReactRouterHonoServerAppLoadContext = UNSAFE_MiddlewareEnabled extends true
|
|
7
|
-
?
|
|
7
|
+
? unstable_RouterContextProvider
|
|
8
8
|
: AppLoadContext;
|
|
9
9
|
|
|
10
10
|
interface HonoServerOptionsBase<E extends Env> {
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-router-hono-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The Vite plugin you need to create a Hono server for your React Router app in less than 10 seconds.",
|
|
6
6
|
"publishConfig": {
|
|
7
|
-
"access": "public"
|
|
7
|
+
"access": "public",
|
|
8
|
+
"provenance": true
|
|
8
9
|
},
|
|
9
10
|
"exports": {
|
|
10
11
|
"./node": {
|
|
@@ -96,7 +97,7 @@
|
|
|
96
97
|
"peerDependencies": {
|
|
97
98
|
"@cloudflare/workers-types": "^4.20250317.0",
|
|
98
99
|
"@hono/node-server": "^1.18.1",
|
|
99
|
-
"@react-router/dev": "^7.
|
|
100
|
+
"@react-router/dev": "^7.8.0",
|
|
100
101
|
"@types/react": "^18.3.10 || ^19.0.0",
|
|
101
102
|
"miniflare": "^3.20241205.0",
|
|
102
103
|
"react-router": "^7.2.0",
|
|
@@ -131,7 +132,7 @@
|
|
|
131
132
|
"validate": "npm run check && npm run tsc",
|
|
132
133
|
"clear-all": "rm -rf node_modules pnpm-lock.yaml && find ./examples -type d -name 'node_modules' -exec rm -rf {} + && find ./examples -name 'pnpm-lock.yaml' -exec rm -f {} +",
|
|
133
134
|
"changeset": "changeset",
|
|
134
|
-
"version": "changeset version",
|
|
135
|
+
"version": "changeset version && biome format --write package.json",
|
|
135
136
|
"release": "changeset publish",
|
|
136
137
|
"changeset:next": "changeset pre enter next",
|
|
137
138
|
"changeset:next:exit": "changeset pre exit"
|