react-router-hono-server 2.20.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 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 a `Map` from it. Check the example for more information.
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-BKrW-3-B.js';
6
- export { c as createGetLoadContext } from '../helpers-BKrW-3-B.js';
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
 
@@ -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-BKrW-3-B.js';
6
- export { c as createGetLoadContext } from '../helpers-BKrW-3-B.js';
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-BKrW-3-B.js';
5
- export { c as createGetLoadContext } from '../helpers-BKrW-3-B.js';
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
 
@@ -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-BKrW-3-B.js';
7
- export { c as createGetLoadContext } from '../helpers-BKrW-3-B.js';
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';
@@ -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, unstable_RouterContext, AppLoadContext } from 'react-router';
4
+ import { ServerBuild, UNSAFE_MiddlewareEnabled, unstable_RouterContextProvider, AppLoadContext } from 'react-router';
5
5
 
6
6
  type ReactRouterHonoServerAppLoadContext = UNSAFE_MiddlewareEnabled extends true
7
- ? Map<unstable_RouterContext, unknown>
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.20.0",
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.2.0",
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",