Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for react-router v7 #10

Merged
merged 4 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading