Skip to content

Commit

Permalink
Support for react-router v7 (#10)
Browse files Browse the repository at this point in the history
* Support for react-router v7
  • Loading branch information
AlemTuzlak authored Nov 23, 2024
1 parent 90c294e commit 406fa0d
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,5 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
/dist
/dist
.history
57 changes: 49 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@remix-run/node": "^2.11.1",
"react-router": "^7.0.0-pre.0",
"@types/node": "^20.12.7",
"@vitest/coverage-v8": "^1.5.2",
"happy-dom": "^14.7.1",
Expand All @@ -71,6 +71,7 @@
},
"peerDependencies": {
"@remix-run/node": "^2.0.0",
"react-router": "^7.0.0-pre.0",
"remix-hono": "^0.0.16",
"hono": "^4.5.3",
"vite": "^5.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/dev-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ const viteDevServer =
* @returns The server build
*/
export async function importDevBuild() {
return viteDevServer?.ssrLoadModule("virtual:remix/server-build");
return viteDevServer?.ssrLoadModule("virtual:react-router/server-build");
}
11 changes: 7 additions & 4 deletions src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import path from "node:path";
import url from "node:url";
import { serve } from "@hono/node-server";
import { serveStatic } from "@hono/node-server/serve-static";
import type { AppLoadContext, ServerBuild } from "@remix-run/node";
import { type Context, type Env, Hono } from "hono";
import type { HonoOptions } from "hono/hono-base";
import { logger } from "hono/logger";
import type { BlankEnv } from "hono/types";
import type { AppLoadContext, ServerBuild } from "react-router";
import { type RemixMiddlewareOptions, remix } from "remix-hono/handler";

import { importDevBuild } from "./dev-build";
Expand Down Expand Up @@ -201,13 +201,16 @@ export async function createHonoServer<E extends Env = BlankEnv>(options: HonoSe
) as ServerBuild;

return remix({
build,
mode,
// biome-ignore lint/suspicious/noExplicitAny: temp
build: build as any,
// biome-ignore lint/suspicious/noExplicitAny: temp
mode: mode as any,
getLoadContext(c) {
if (!mergedOptions.getLoadContext) {
return {};
}
return mergedOptions.getLoadContext(c, { build });
// biome-ignore lint/suspicious/noExplicitAny: temp
return mergedOptions.getLoadContext(c, { build: build as any });
},
})(c, next);
});
Expand Down

0 comments on commit 406fa0d

Please sign in to comment.