-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 12debe2
Showing
18 changed files
with
22,579 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": ["@remix-run/eslint-config", "@remix-run/eslint-config/node"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
|
||
/.cache | ||
/build | ||
/public/build | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# React Router + Remix | ||
|
||
This is an example of how you can incrementally migrate to Remix if you're using React Router. Here's the basic idea: | ||
|
||
1. Upgrade your React Router site to the latest version of React Router ([find out how to do this iteratively](https://www.npmjs.com/package/react-router-dom-v5-compat)). | ||
2. Install Remix and set up the conventional files of `app/{root,entry.client,entry.server}.tsx` | ||
3. Move all your existing code into a directory within the `app` directory (like `app/old-app` for example). | ||
4. Remove `<BrowserRouter>` from your `App` | ||
5. Create a `app/routes.$.tsx` file with just `export { default } from "~/old-app/app";` (or whatever file has the root component for your existing React Router app). | ||
6. Everything should work at this point (_and_ it'll be server rendered too!!). Commit + push! | ||
7. Over time, move old routes to the `routes` directory until you bring everything over. | ||
8. You're done! | ||
|
||
We'll have better docs and even videos about this in the future, but this is a pretty darn solid and iterative approach with quick wins and a clear path. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { RemixBrowser } from "@remix-run/react"; | ||
import { hydrate } from "react-dom"; | ||
|
||
hydrate(<RemixBrowser />, document); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { EntryContext } from "@remix-run/node"; | ||
import { RemixServer } from "@remix-run/react"; | ||
import { renderToString } from "react-dom/server"; | ||
|
||
export default function handleRequest( | ||
request: Request, | ||
responseStatusCode: number, | ||
responseHeaders: Headers, | ||
remixContext: EntryContext | ||
) { | ||
let markup = renderToString( | ||
<RemixServer context={remixContext} url={request.url} /> | ||
); | ||
|
||
responseHeaders.set("Content-Type", "text/html"); | ||
|
||
return new Response("<!DOCTYPE html>" + markup, { | ||
status: responseStatusCode, | ||
headers: responseHeaders, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from "react"; | ||
|
||
import { Routes, Route } from "react-router-dom"; | ||
import { PageFour } from "./pages/page-4"; | ||
import { PageTwo } from "./pages/page-2"; | ||
|
||
function App() { | ||
return ( | ||
<div> | ||
<div>Old app</div> | ||
<Routes> | ||
<Route path="/page2" element={<PageTwo />} /> | ||
<Route path="/page4" element={<PageFour />} /> | ||
</Routes> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Link } from "react-router-dom"; | ||
|
||
export function PageTwo() { | ||
return ( | ||
<div> | ||
<main> | ||
<p>Page 2 (old)</p> | ||
|
||
<Link to="/">Go home (remix)</Link> | ||
<br /> | ||
<Link to="/page3">Go to page 3 (remix)</Link> | ||
<br /> | ||
<Link to="/page4">Go to page 4 (old)</Link> | ||
</main> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Link } from "react-router-dom"; | ||
|
||
export function PageFour() { | ||
return ( | ||
<div> | ||
<main> | ||
<p>Page 4</p> | ||
|
||
<Link to="/">Go Home (remix)</Link> | ||
<br /> | ||
<Link to="/page2">Go to page 2 (old)</Link> | ||
<br /> | ||
<Link to="/page3">Go to page 3 (remix)</Link> | ||
</main> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { MetaFunction } from "@remix-run/node"; | ||
import { | ||
Links, | ||
LiveReload, | ||
Meta, | ||
Outlet, | ||
Scripts, | ||
ScrollRestoration, | ||
} from "@remix-run/react"; | ||
|
||
export const meta: MetaFunction = () => ({ | ||
charset: "utf-8", | ||
title: "New Remix App", | ||
viewport: "width=device-width,initial-scale=1", | ||
}); | ||
|
||
export default function App() { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<Meta /> | ||
<Links /> | ||
</head> | ||
<body> | ||
<Outlet /> | ||
<ScrollRestoration /> | ||
<Scripts /> | ||
<LiveReload /> | ||
</body> | ||
</html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "~/old-app/app"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Link } from "@remix-run/react"; | ||
|
||
export default function Page3() { | ||
return ( | ||
<div> | ||
<main> | ||
<p>Home (remix)</p> | ||
|
||
<Link to="/page2">Go to page 2 (old)</Link> | ||
<br /> | ||
<Link to="/page3">Go to page 3 (remix)</Link> | ||
<br /> | ||
<Link to="/page4">Go to page 4 (old)</Link> | ||
</main> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Link } from "@remix-run/react"; | ||
|
||
export default function Page3() { | ||
return ( | ||
<div> | ||
<main> | ||
<p>Page 3 (remix)</p> | ||
|
||
<Link to="/page2">Go home (remix)</Link> | ||
<br /> | ||
<Link to="/page3">Go to page 3 (remix)</Link> | ||
<br /> | ||
<Link to="/page4">Go to page 4 (old)</Link> | ||
</main> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.