react-router-hono-server 2.21.0 → 2.23.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
@@ -507,6 +507,19 @@ export type HonoServerOptions<E extends Env = BlankEnv> = {
507
507
  * }
508
508
  * }
509
509
  * ```
510
+ *
511
+ * **To make the typing works correctly, in your `react-router.config.ts`, add future v8_middleware flag to true.**
512
+ *
513
+ * ```ts
514
+ * import { defineConfig } from "@react-router/dev";
515
+ *
516
+ * export default defineConfig({
517
+ * future: {
518
+ * v8_middleware: true,
519
+ * },
520
+ * // other config options...
521
+ * });
522
+ * ```
510
523
  */
511
524
  getLoadContext?: (
512
525
  c: Context,
@@ -650,7 +663,7 @@ export interface HonoServerOptions<E extends Env = BlankEnv> extends HonoServerO
650
663
  *
651
664
  * {@link https://bun.sh/docs/api/http#start-a-server-bun-serve}
652
665
  */
653
- customBunServer?: Serve & ServeOptions;
666
+ customBunServer?: Serve.Options<unknown, string>;
654
667
  /**
655
668
  * Customize the serve static options
656
669
  */
@@ -814,19 +827,27 @@ export default createHonoServer({
814
827
  });
815
828
  ```
816
829
 
817
- ### Using React Router Middleware (unstable future)
830
+ ### Using React Router Middleware
818
831
  You can use React Router middleware with this package.
819
832
 
820
833
  > [!TIP]
821
834
  > Check this [example](./examples/node/simple-future-middleware/) to see how to use it.
822
835
 
823
836
  > [!IMPORTANT]
824
- > Please note that this is an unstable feature and could change in the future.
837
+ > **To make the typing works correctly, in your `react-router.config.ts` or where you want, add future v8_middleware flag type to true.**
838
+ >
839
+ > ```ts
840
+ > declare module "react-router" {
841
+ > interface Future {
842
+ > v8_middleware: true; // 👈 Enable middleware types
843
+ > }
844
+ > }
845
+ > ```
825
846
  >
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.
847
+ > If you already have a custom `getLoadContext` function, you now have to return an instance of `RouterContextProvider` from it. Check this [example](./examples/node/simple-future-middleware/) for more information.
827
848
  >
828
849
  > ```ts
829
- > import { unstable_RouterContextProvider, unstable_createContext } from "react-router";
850
+ > import { RouterContextProvider, createContext } from "react-router";
830
851
  > import { createHonoServer } from "react-router-hono-server/node";
831
852
  >
832
853
  > console.log("loading server");
@@ -835,12 +856,12 @@ You can use React Router middleware with this package.
835
856
  > appVersion: string;
836
857
  > };
837
858
  >
838
- > export const globalAppContext = unstable_createContext<GlobalAppContext>();
859
+ > export const globalAppContext = createContext<GlobalAppContext>();
839
860
  >
840
861
  > export default await createHonoServer({
841
862
  > getLoadContext(_c, { mode, build }) {
842
863
  > const isProductionMode = mode === "production";
843
- > const context = new unstable_RouterContextProvider();
864
+ > const context = new RouterContextProvider();
844
865
  >
845
866
  > context.set(globalAppContext, { appVersion: isProductionMode ? build.assets.version : "dev" });
846
867
  >
@@ -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-BcJiNpMs.js';
6
- export { c as createGetLoadContext } from '../helpers-BcJiNpMs.js';
5
+ import { H as HonoServerOptionsBase, W as WithoutWebsocket } from '../helpers-BXdVojwF.js';
6
+ export { c as createGetLoadContext } from '../helpers-BXdVojwF.js';
7
7
  import 'hono/ws';
8
8
  import 'react-router';
9
9
 
@@ -3,7 +3,7 @@ import {
3
3
  createGetLoadContext,
4
4
  getBuildMode,
5
5
  importBuild
6
- } from "../chunk-XPXQNPY3.js";
6
+ } from "../chunk-BH64OQMW.js";
7
7
  import {
8
8
  cache
9
9
  } from "../chunk-YI5FED4X.js";
@@ -1,15 +1,13 @@
1
- import { Serve, ServeOptions } from 'bun';
1
+ import { Serve } 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-BcJiNpMs.js';
6
- export { c as createGetLoadContext } from '../helpers-BcJiNpMs.js';
5
+ import { H as HonoServerOptionsBase, a as WithWebsocket, W as WithoutWebsocket } from '../helpers-BXdVojwF.js';
6
+ export { c as createGetLoadContext } from '../helpers-BXdVojwF.js';
7
7
  import 'hono/ws';
8
8
  import 'react-router';
9
9
 
10
- type CustomBunServer = Serve & ServeOptions & {
11
- websocket?: unknown;
12
- };
10
+ type CustomBunServer = Serve.Options<unknown, string>;
13
11
  interface HonoBunServerOptions<E extends Env = BlankEnv> extends HonoServerOptionsBase<E> {
14
12
  /**
15
13
  * Customize the bun server
@@ -6,7 +6,7 @@ import {
6
6
  getBuildMode,
7
7
  importBuild,
8
8
  patchUpgradeListener
9
- } from "../chunk-XPXQNPY3.js";
9
+ } from "../chunk-BH64OQMW.js";
10
10
  import {
11
11
  cache
12
12
  } from "../chunk-YI5FED4X.js";
@@ -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-BcJiNpMs.js';
5
- export { c as createGetLoadContext } from '../helpers-BcJiNpMs.js';
4
+ import { H as HonoServerOptionsBase, W as WithoutWebsocket } from '../helpers-BXdVojwF.js';
5
+ export { c as createGetLoadContext } from '../helpers-BXdVojwF.js';
6
6
  import 'hono/ws';
7
7
  import 'react-router';
8
8
 
@@ -3,7 +3,7 @@ import {
3
3
  createGetLoadContext,
4
4
  getBuildMode,
5
5
  importBuild
6
- } from "../chunk-XPXQNPY3.js";
6
+ } from "../chunk-BH64OQMW.js";
7
7
  import {
8
8
  cache
9
9
  } from "../chunk-YI5FED4X.js";
@@ -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-BcJiNpMs.js';
7
- export { c as createGetLoadContext } from '../helpers-BcJiNpMs.js';
6
+ import { H as HonoServerOptionsBase, a as WithWebsocket, W as WithoutWebsocket } from '../helpers-BXdVojwF.js';
7
+ export { c as createGetLoadContext } from '../helpers-BXdVojwF.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';
@@ -6,7 +6,7 @@ import {
6
6
  getBuildMode,
7
7
  importBuild,
8
8
  patchUpgradeListener
9
- } from "../chunk-XPXQNPY3.js";
9
+ } from "../chunk-BH64OQMW.js";
10
10
  import {
11
11
  cache
12
12
  } from "../chunk-YI5FED4X.js";
@@ -1,8 +1,8 @@
1
1
  // src/helpers.ts
2
2
  import { createMiddleware } from "hono/factory";
3
3
  var defaultWebSocket = {
4
- upgradeWebSocket: () => {
5
- },
4
+ upgradeWebSocket: (() => {
5
+ }),
6
6
  injectWebSocket: (server) => server
7
7
  };
8
8
  async function createWebSocket({ app, enabled }) {
@@ -43,7 +43,7 @@ function cleanUpgradeListeners(httpServer) {
43
43
  for (const listener of upgradeListeners) {
44
44
  httpServer.removeListener(
45
45
  "upgrade",
46
- /* @ts-ignore - we don't care */
46
+ /* @ts-expect-error - we don't care */
47
47
  listener
48
48
  );
49
49
  }
@@ -53,7 +53,7 @@ function patchUpgradeListener(httpServer) {
53
53
  for (const listener of upgradeListeners) {
54
54
  httpServer.removeListener(
55
55
  "upgrade",
56
- /* @ts-ignore - we don't care */
56
+ /* @ts-expect-error - we don't care */
57
57
  listener
58
58
  );
59
59
  httpServer.on("upgrade", (request, ...rest) => {
package/dist/dev.js CHANGED
@@ -70,7 +70,7 @@ Please add it to your plugins: import { cloudflareDevProxy } from "@react-router
70
70
  if (reactRouterBuildFile === "index.js") {
71
71
  reactRouterBuildFile = "assets/server-build.js";
72
72
  }
73
- let alias = void 0;
73
+ let alias = {};
74
74
  if (runtime === "cloudflare") {
75
75
  const reactVersion = await getReactVersion(pluginConfig);
76
76
  alias = {
@@ -268,7 +268,7 @@ async function getReactVersion(pluginConfig) {
268
268
  }
269
269
  const reactPackage = await import("react");
270
270
  const version = reactPackage.default.version || reactPackage.version;
271
- return Number.parseInt(version.split(".")[0]);
271
+ return Number.parseInt(version.split(".")[0], 10);
272
272
  }
273
273
  function isCloudflareOptions(options) {
274
274
  return options.runtime === "cloudflare";
@@ -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_RouterContextProvider, AppLoadContext } from 'react-router';
4
+ import { ServerBuild, UNSAFE_MiddlewareEnabled, RouterContextProvider, AppLoadContext } from 'react-router';
5
5
 
6
6
  type ReactRouterHonoServerAppLoadContext = UNSAFE_MiddlewareEnabled extends true
7
- ? unstable_RouterContextProvider
7
+ ? RouterContextProvider
8
8
  : AppLoadContext;
9
9
 
10
10
  interface HonoServerOptionsBase<E extends Env> {
@@ -42,6 +42,16 @@ interface HonoServerOptionsBase<E extends Env> {
42
42
  * }
43
43
  * }
44
44
  * ```
45
+ *
46
+ * **To make the typing works correctly, in your `react-router.config.ts` or where you want, add future v8_middleware flag type to true.**
47
+ *
48
+ * ```ts
49
+ * declare module "react-router" {
50
+ * interface Future {
51
+ * v8_middleware: true; // 👈 Enable middleware types
52
+ * }
53
+ * }
54
+ * ```
45
55
  */
46
56
  getLoadContext?: (
47
57
  c: Context<E>,
@@ -5,6 +5,6 @@ import * as hono from 'hono';
5
5
  *
6
6
  * @param seconds - The number of seconds to cache
7
7
  */
8
- declare function cache(seconds: number): hono.MiddlewareHandler<any, string, {}>;
8
+ declare function cache(seconds: number): hono.MiddlewareHandler<any, string, {}, Response>;
9
9
 
10
10
  export { cache };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router-hono-server",
3
- "version": "2.21.0",
3
+ "version": "2.23.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": {
@@ -76,32 +76,32 @@
76
76
  "homepage": "https://github.com/rphlmr/react-router-hono-server#readme",
77
77
  "dependencies": {
78
78
  "@drizzle-team/brocli": "^0.11.0",
79
- "@hono/node-server": "^1.18.1",
79
+ "@hono/node-server": "^1.19.5",
80
80
  "@hono/node-ws": "^1.2.0",
81
- "@hono/vite-dev-server": "^0.20.0",
82
- "hono": "^4.7.5"
81
+ "@hono/vite-dev-server": "^0.23.0",
82
+ "hono": "^4.11.4"
83
83
  },
84
84
  "devDependencies": {
85
- "@biomejs/biome": "^1.9.4",
86
- "@changesets/cli": "^2.29.5",
85
+ "@biomejs/biome": "^2.3.1",
86
+ "@changesets/cli": "^2.29.7",
87
87
  "@cloudflare/workers-types": "^4.20250405.0",
88
- "@types/bun": "^1.2.8",
89
- "@types/node": "^22.14.0",
90
- "@vitest/coverage-v8": "^3.1.1",
91
- "lefthook": "^1.11.6",
88
+ "@types/bun": "^1.3.1",
89
+ "@types/node": "^22.18.12",
90
+ "@vitest/coverage-v8": "^4.0.4",
91
+ "lefthook": "^1.13.6",
92
92
  "npm-run-all": "^4.1.5",
93
- "tsup": "^8.4.0",
94
- "typescript": "^5.8.3",
95
- "vitest": "^3.1.1"
93
+ "tsup": "^8.5.0",
94
+ "typescript": "^5.9.3",
95
+ "vitest": "^4.0.4"
96
96
  },
97
97
  "peerDependencies": {
98
98
  "@cloudflare/workers-types": "^4.20250317.0",
99
- "@hono/node-server": "^1.18.1",
100
- "@react-router/dev": "^7.8.0",
101
- "@types/react": "^18.3.10 || ^19.0.0",
99
+ "@hono/node-server": "^1.19.0",
100
+ "@react-router/dev": "^7.9.0",
101
+ "@types/react": "^19.0.0",
102
102
  "miniflare": "^3.20241205.0",
103
- "react-router": "^7.2.0",
104
- "vite": "^6.0.0 || ^7.0.0",
103
+ "react-router": "^7.9.0",
104
+ "vite": "^7.0.0",
105
105
  "wrangler": "^4.2.0"
106
106
  },
107
107
  "peerDependenciesMeta": {
@@ -119,7 +119,7 @@
119
119
  }
120
120
  },
121
121
  "engines": {
122
- "node": ">=22.12.0"
122
+ "node": ">=22.20.0"
123
123
  },
124
124
  "scripts": {
125
125
  "test": "vitest run",