generated from chiffre-io/template-library
-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added react-router v7 support (#785)
* chore: install react-router v7 * ref: adding react-router v6 and v7 * build: add react-router v6 v7 in commonConfig, entrypoint, and package.json * doc: update comment path in react-router d.ts related files * doc: add a note for react-router in docs * chore: Fix sherif * test: Split RRv6 & RRv7 e2e test benches * chore: Formatting * chore: Normalise ports * chore: CI name formatting * chore: Use explicit RRv6 adapter in e2e test bench * chore: Add nuqs to RRv7 e2e test bench * doc: Update message in react-router shorthand adapter --------- Co-authored-by: Francois Best <[email protected]>
- Loading branch information
Showing
43 changed files
with
712 additions
and
50 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
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
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
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 |
---|---|---|
@@ -1,35 +1,5 @@ | ||
{ | ||
"name": "e2e-react-router", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite --port 4000", | ||
"build": "tsc -b && vite build", | ||
"preview": "vite preview", | ||
"test": "pnpm run '/^test:/'", | ||
"test:unit": "vitest", | ||
"test:e2e": "echo 'todo: Implement e2e tests'" | ||
}, | ||
"dependencies": { | ||
"nuqs": "workspace:*", | ||
"react": "catalog:react19", | ||
"react-dom": "catalog:react19", | ||
"react-router-dom": "^6.28.0" | ||
}, | ||
"devDependencies": { | ||
"@testing-library/dom": "^10.4.0", | ||
"@testing-library/jest-dom": "^6.6.3", | ||
"@testing-library/react": "^16.0.1", | ||
"@testing-library/user-event": "^14.5.2", | ||
"@types/node": "^22.9.0", | ||
"@types/react": "catalog:react19", | ||
"@types/react-dom": "catalog:react19", | ||
"@vitejs/plugin-react": "^4.3.3", | ||
"globals": "^15.12.0", | ||
"jsdom": "^25.0.1", | ||
"typescript": "^5.6.3", | ||
"vite": "^5.4.11", | ||
"vitest": "^2.1.5" | ||
} | ||
"private": true | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,35 @@ | ||
{ | ||
"name": "e2e-react-router-v6", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite --port 3006", | ||
"build": "tsc -b && vite build", | ||
"preview": "vite preview", | ||
"test": "pnpm run '/^test:/'", | ||
"test:unit": "vitest", | ||
"test:e2e": "echo 'todo: Implement e2e tests'" | ||
}, | ||
"dependencies": { | ||
"nuqs": "workspace:*", | ||
"react": "catalog:react19", | ||
"react-dom": "catalog:react19", | ||
"react-router-dom": "^6.28.0" | ||
}, | ||
"devDependencies": { | ||
"@testing-library/dom": "^10.4.0", | ||
"@testing-library/jest-dom": "^6.6.3", | ||
"@testing-library/react": "^16.0.1", | ||
"@testing-library/user-event": "^14.5.2", | ||
"@types/node": "^22.9.0", | ||
"@types/react": "catalog:react19", | ||
"@types/react-dom": "catalog:react19", | ||
"@vitejs/plugin-react": "^4.3.3", | ||
"globals": "^15.12.0", | ||
"jsdom": "^25.0.1", | ||
"typescript": "^5.6.3", | ||
"vite": "^5.4.11", | ||
"vitest": "^2.1.5" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ges/e2e/react-router/src/react-router.tsx → .../e2e/react-router/v6/src/react-router.tsx
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 @@ | ||
.DS_Store | ||
/node_modules/ | ||
|
||
# React Router | ||
/.react-router/ | ||
/build/ |
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,100 @@ | ||
# Welcome to React Router! | ||
|
||
A modern, production-ready template for building full-stack React applications using React Router. | ||
|
||
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router-templates/tree/main/default) | ||
|
||
## Features | ||
|
||
- 🚀 Server-side rendering | ||
- ⚡️ Hot Module Replacement (HMR) | ||
- 📦 Asset bundling and optimization | ||
- 🔄 Data loading and mutations | ||
- 🔒 TypeScript by default | ||
- 🎉 TailwindCSS for styling | ||
- 📖 [React Router docs](https://reactrouter.com/) | ||
|
||
## Getting Started | ||
|
||
### Installation | ||
|
||
Install the dependencies: | ||
|
||
```bash | ||
npm install | ||
``` | ||
|
||
### Development | ||
|
||
Start the development server with HMR: | ||
|
||
```bash | ||
npm run dev | ||
``` | ||
|
||
Your application will be available at `http://localhost:5173`. | ||
|
||
## Building for Production | ||
|
||
Create a production build: | ||
|
||
```bash | ||
npm run build | ||
``` | ||
|
||
## Deployment | ||
|
||
### Docker Deployment | ||
|
||
This template includes three Dockerfiles optimized for different package managers: | ||
|
||
- `Dockerfile` - for npm | ||
- `Dockerfile.pnpm` - for pnpm | ||
- `Dockerfile.bun` - for bun | ||
|
||
To build and run using Docker: | ||
|
||
```bash | ||
# For npm | ||
docker build -t my-app . | ||
|
||
# For pnpm | ||
docker build -f Dockerfile.pnpm -t my-app . | ||
|
||
# For bun | ||
docker build -f Dockerfile.bun -t my-app . | ||
|
||
# Run the container | ||
docker run -p 3000:3000 my-app | ||
``` | ||
|
||
The containerized application can be deployed to any platform that supports Docker, including: | ||
|
||
- AWS ECS | ||
- Google Cloud Run | ||
- Azure Container Apps | ||
- Digital Ocean App Platform | ||
- Fly.io | ||
- Railway | ||
|
||
### DIY Deployment | ||
|
||
If you're familiar with deploying Node applications, the built-in app server is production-ready. | ||
|
||
Make sure to deploy the output of `npm run build` | ||
|
||
``` | ||
├── package.json | ||
├── package-lock.json (or pnpm-lock.yaml, or bun.lockb) | ||
├── build/ | ||
│ ├── client/ # Static assets | ||
│ └── server/ # Server-side code | ||
``` | ||
|
||
## Styling | ||
|
||
This template comes with [Tailwind CSS](https://tailwindcss.com/) already configured for a simple default starting experience. You can use whatever CSS framework you prefer. | ||
|
||
--- | ||
|
||
Built with ❤️ using React Router. |
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,66 @@ | ||
import { NuqsAdapter } from 'nuqs/adapters/react-router/v7' | ||
import { | ||
isRouteErrorResponse, | ||
Links, | ||
Meta, | ||
Outlet, | ||
Scripts, | ||
ScrollRestoration | ||
} from 'react-router' | ||
|
||
import type { Route } from './+types/root' | ||
|
||
export function Layout({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<Meta /> | ||
<Links /> | ||
</head> | ||
<body> | ||
{children} | ||
<ScrollRestoration /> | ||
<Scripts /> | ||
</body> | ||
</html> | ||
) | ||
} | ||
|
||
export default function App() { | ||
return ( | ||
<NuqsAdapter> | ||
<Outlet /> | ||
</NuqsAdapter> | ||
) | ||
} | ||
|
||
export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) { | ||
let message = 'Oops!' | ||
let details = 'An unexpected error occurred.' | ||
let stack: string | undefined | ||
|
||
if (isRouteErrorResponse(error)) { | ||
message = error.status === 404 ? '404' : 'Error' | ||
details = | ||
error.status === 404 | ||
? 'The requested page could not be found.' | ||
: error.statusText || details | ||
} else if (import.meta.env.DEV && error && error instanceof Error) { | ||
details = error.message | ||
stack = error.stack | ||
} | ||
|
||
return ( | ||
<main className="pt-16 p-4 container mx-auto"> | ||
<h1>{message}</h1> | ||
<p>{details}</p> | ||
{stack && ( | ||
<pre className="w-full p-4 overflow-x-auto"> | ||
<code>{stack}</code> | ||
</pre> | ||
)} | ||
</main> | ||
) | ||
} |
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 @@ | ||
import { type RouteConfig, index } from "@react-router/dev/routes"; | ||
|
||
export default [index("routes/home.tsx")] satisfies RouteConfig; |
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,12 @@ | ||
import type { Route } from './+types/home' | ||
|
||
export function meta({}: Route.MetaArgs) { | ||
return [ | ||
{ title: 'New React Router App' }, | ||
{ name: 'description', content: 'Welcome to React Router!' } | ||
] | ||
} | ||
|
||
export default function Home() { | ||
return <p>Hello, RRv7</p> | ||
} |
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,29 @@ | ||
{ | ||
"name": "e2e-react-router-v7", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"build": "react-router build", | ||
"dev": "react-router dev --port 3007", | ||
"start": "react-router-serve ./build/server/index.js", | ||
"typecheck": "react-router typegen && tsc" | ||
}, | ||
"dependencies": { | ||
"@react-router/node": "^7.0.2", | ||
"@react-router/serve": "^7.0.2", | ||
"isbot": "^5.1.17", | ||
"nuqs": "workspace:*", | ||
"react": "catalog:react19", | ||
"react-dom": "catalog:react19", | ||
"react-router": "^7.0.2" | ||
}, | ||
"devDependencies": { | ||
"@react-router/dev": "^7.0.2", | ||
"@types/node": "^20", | ||
"@types/react": "catalog:react19", | ||
"@types/react-dom": "catalog:react19", | ||
"typescript": "^5.6.3", | ||
"vite": "^5.4.11", | ||
"vite-tsconfig-paths": "^5.1.2" | ||
} | ||
} |
Binary file not shown.
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,7 @@ | ||
import type { Config } from "@react-router/dev/config"; | ||
|
||
export default { | ||
// Config options... | ||
// Server-side render by default, to enable SPA mode set this to `false` | ||
ssr: true, | ||
} satisfies Config; |
Oops, something went wrong.