Skip to content

Commit c3a5f5d

Browse files
committed
Initial commit from create-react-router
0 parents  commit c3a5f5d

20 files changed

+5675
-0
lines changed

.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.react-router
2+
build
3+
node_modules
4+
README.md

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
/node_modules/
3+
4+
# React Router
5+
/.react-router/
6+
/build/

Dockerfile

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM node:20-alpine AS development-dependencies-env
2+
COPY . /app
3+
WORKDIR /app
4+
RUN npm ci
5+
6+
FROM node:20-alpine AS production-dependencies-env
7+
COPY ./package.json package-lock.json /app/
8+
WORKDIR /app
9+
RUN npm ci --omit=dev
10+
11+
FROM node:20-alpine AS build-env
12+
COPY . /app/
13+
COPY --from=development-dependencies-env /app/node_modules /app/node_modules
14+
WORKDIR /app
15+
RUN npm run build
16+
17+
FROM node:20-alpine
18+
COPY ./package.json package-lock.json /app/
19+
COPY --from=production-dependencies-env /app/node_modules /app/node_modules
20+
COPY --from=build-env /app/build /app/build
21+
WORKDIR /app
22+
CMD ["npm", "run", "start"]

Dockerfile.bun

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM oven/bun:1 AS dependencies-env
2+
COPY . /app
3+
4+
FROM dependencies-env AS development-dependencies-env
5+
COPY ./package.json bun.lockb /app/
6+
WORKDIR /app
7+
RUN bun i --frozen-lockfile
8+
9+
FROM dependencies-env AS production-dependencies-env
10+
COPY ./package.json bun.lockb /app/
11+
WORKDIR /app
12+
RUN bun i --production
13+
14+
FROM dependencies-env AS build-env
15+
COPY ./package.json bun.lockb /app/
16+
COPY --from=development-dependencies-env /app/node_modules /app/node_modules
17+
WORKDIR /app
18+
RUN bun run build
19+
20+
FROM dependencies-env
21+
COPY ./package.json bun.lockb /app/
22+
COPY --from=production-dependencies-env /app/node_modules /app/node_modules
23+
COPY --from=build-env /app/build /app/build
24+
WORKDIR /app
25+
CMD ["bun", "run", "start"]

Dockerfile.pnpm

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM node:20-alpine AS dependencies-env
2+
RUN npm i -g pnpm
3+
COPY . /app
4+
5+
FROM dependencies-env AS development-dependencies-env
6+
COPY ./package.json pnpm-lock.yaml /app/
7+
WORKDIR /app
8+
RUN pnpm i --frozen-lockfile
9+
10+
FROM dependencies-env AS production-dependencies-env
11+
COPY ./package.json pnpm-lock.yaml /app/
12+
WORKDIR /app
13+
RUN pnpm i --prod --frozen-lockfile
14+
15+
FROM dependencies-env AS build-env
16+
COPY ./package.json pnpm-lock.yaml /app/
17+
COPY --from=development-dependencies-env /app/node_modules /app/node_modules
18+
WORKDIR /app
19+
RUN pnpm build
20+
21+
FROM dependencies-env
22+
COPY ./package.json pnpm-lock.yaml /app/
23+
COPY --from=production-dependencies-env /app/node_modules /app/node_modules
24+
COPY --from=build-env /app/build /app/build
25+
WORKDIR /app
26+
CMD ["pnpm", "start"]

README.md

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Welcome to React Router!
2+
3+
A modern, production-ready template for building full-stack React applications using React Router.
4+
5+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router-templates/tree/main/default)
6+
7+
## Features
8+
9+
- 🚀 Server-side rendering
10+
- ⚡️ Hot Module Replacement (HMR)
11+
- 📦 Asset bundling and optimization
12+
- 🔄 Data loading and mutations
13+
- 🔒 TypeScript by default
14+
- 🎉 TailwindCSS for styling
15+
- 📖 [React Router docs](https://reactrouter.com/)
16+
17+
## Getting Started
18+
19+
### Installation
20+
21+
Install the dependencies:
22+
23+
```bash
24+
npm install
25+
```
26+
27+
### Development
28+
29+
Start the development server with HMR:
30+
31+
```bash
32+
npm run dev
33+
```
34+
35+
Your application will be available at `http://localhost:5173`.
36+
37+
## Building for Production
38+
39+
Create a production build:
40+
41+
```bash
42+
npm run build
43+
```
44+
45+
## Deployment
46+
47+
### Docker Deployment
48+
49+
This template includes three Dockerfiles optimized for different package managers:
50+
51+
- `Dockerfile` - for npm
52+
- `Dockerfile.pnpm` - for pnpm
53+
- `Dockerfile.bun` - for bun
54+
55+
To build and run using Docker:
56+
57+
```bash
58+
# For npm
59+
docker build -t my-app .
60+
61+
# For pnpm
62+
docker build -f Dockerfile.pnpm -t my-app .
63+
64+
# For bun
65+
docker build -f Dockerfile.bun -t my-app .
66+
67+
# Run the container
68+
docker run -p 3000:3000 my-app
69+
```
70+
71+
The containerized application can be deployed to any platform that supports Docker, including:
72+
73+
- AWS ECS
74+
- Google Cloud Run
75+
- Azure Container Apps
76+
- Digital Ocean App Platform
77+
- Fly.io
78+
- Railway
79+
80+
### DIY Deployment
81+
82+
If you're familiar with deploying Node applications, the built-in app server is production-ready.
83+
84+
Make sure to deploy the output of `npm run build`
85+
86+
```
87+
├── package.json
88+
├── package-lock.json (or pnpm-lock.yaml, or bun.lockb)
89+
├── build/
90+
│ ├── client/ # Static assets
91+
│ └── server/ # Server-side code
92+
```
93+
94+
## Styling
95+
96+
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.
97+
98+
---
99+
100+
Built with ❤️ using React Router.

app/app.css

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
html,
6+
body {
7+
@apply bg-white dark:bg-gray-950;
8+
9+
@media (prefers-color-scheme: dark) {
10+
color-scheme: dark;
11+
}
12+
}

app/root.tsx

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import {
2+
isRouteErrorResponse,
3+
Links,
4+
Meta,
5+
Outlet,
6+
Scripts,
7+
ScrollRestoration,
8+
} from "react-router";
9+
10+
import type { Route } from "./+types/root";
11+
import stylesheet from "./app.css?url";
12+
13+
export const links: Route.LinksFunction = () => [
14+
{ rel: "preconnect", href: "https://fonts.googleapis.com" },
15+
{
16+
rel: "preconnect",
17+
href: "https://fonts.gstatic.com",
18+
crossOrigin: "anonymous",
19+
},
20+
{
21+
rel: "stylesheet",
22+
href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",
23+
},
24+
{ rel: "stylesheet", href: stylesheet },
25+
];
26+
27+
export function Layout({ children }: { children: React.ReactNode }) {
28+
return (
29+
<html lang="en">
30+
<head>
31+
<meta charSet="utf-8" />
32+
<meta name="viewport" content="width=device-width, initial-scale=1" />
33+
<Meta />
34+
<Links />
35+
</head>
36+
<body>
37+
{children}
38+
<ScrollRestoration />
39+
<Scripts />
40+
</body>
41+
</html>
42+
);
43+
}
44+
45+
export default function App() {
46+
return <Outlet />;
47+
}
48+
49+
export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
50+
let message = "Oops!";
51+
let details = "An unexpected error occurred.";
52+
let stack: string | undefined;
53+
54+
if (isRouteErrorResponse(error)) {
55+
message = error.status === 404 ? "404" : "Error";
56+
details =
57+
error.status === 404
58+
? "The requested page could not be found."
59+
: error.statusText || details;
60+
} else if (import.meta.env.DEV && error && error instanceof Error) {
61+
details = error.message;
62+
stack = error.stack;
63+
}
64+
65+
return (
66+
<main className="pt-16 p-4 container mx-auto">
67+
<h1>{message}</h1>
68+
<p>{details}</p>
69+
{stack && (
70+
<pre className="w-full p-4 overflow-x-auto">
71+
<code>{stack}</code>
72+
</pre>
73+
)}
74+
</main>
75+
);
76+
}

app/routes.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { type RouteConfig, index } from "@react-router/dev/routes";
2+
3+
export default [index("routes/home.tsx")] satisfies RouteConfig;

app/routes/home.tsx

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { Route } from "./+types/home";
2+
import { Welcome } from "../welcome/welcome";
3+
4+
export function meta({}: Route.MetaArgs) {
5+
return [
6+
{ title: "New React Router App" },
7+
{ name: "description", content: "Welcome to React Router!" },
8+
];
9+
}
10+
11+
export default function Home() {
12+
return <Welcome />;
13+
}

app/welcome/logo-dark.svg

+23
Loading

app/welcome/logo-light.svg

+23
Loading

0 commit comments

Comments
 (0)