-
Notifications
You must be signed in to change notification settings - Fork 113
WIP: Add unstable RSC Framework Mode template #158
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4586abd
Add unstable RSC Framework Mode template
markdalgleish 9765b64
Update lockfile
markdalgleish ab57d60
Remove generated types, update gitignore
markdalgleish aa0a8e6
Convert home route to server component
markdalgleish ada619e
simplify rsc framework template and use react-router-serve
jacob-ebey 48b2c02
update version
jacob-ebey b40f494
add vite-tsconfig-paths
jacob-ebey f14b32b
remove comments
jacob-ebey 1b2d682
update version
jacob-ebey e411692
Bump deps
brookslybrand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 hidden or 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,2 @@ | ||
| build | ||
| node_modules |
This file contains hidden or 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,9 @@ | ||
| // Generated by React Router | ||
|
|
||
| import "react-router"; | ||
|
|
||
| declare module "react-router" { | ||
| interface Future { | ||
| v8_middleware: false | ||
| } | ||
| } |
27 changes: 27 additions & 0 deletions
27
unstable_rsc-framework-mode/.react-router/types/+routes.ts
This file contains hidden or 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,27 @@ | ||
| // Generated by React Router | ||
|
|
||
| import "react-router" | ||
|
|
||
| declare module "react-router" { | ||
| interface Register { | ||
| pages: Pages | ||
| routeFiles: RouteFiles | ||
| } | ||
| } | ||
|
|
||
| type Pages = { | ||
| "/": { | ||
| params: {}; | ||
| }; | ||
| }; | ||
|
|
||
| type RouteFiles = { | ||
| "root.tsx": { | ||
| id: "root"; | ||
| page: "/"; | ||
| }; | ||
| "routes/home.tsx": { | ||
| id: "routes/home"; | ||
| page: "/"; | ||
| }; | ||
| }; |
17 changes: 17 additions & 0 deletions
17
unstable_rsc-framework-mode/.react-router/types/+server-build.d.ts
This file contains hidden or 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 @@ | ||
| // Generated by React Router | ||
|
|
||
| declare module "virtual:react-router/server-build" { | ||
| import { ServerBuild } from "react-router"; | ||
| export const assets: ServerBuild["assets"]; | ||
| export const assetsBuildDirectory: ServerBuild["assetsBuildDirectory"]; | ||
| export const basename: ServerBuild["basename"]; | ||
| export const entry: ServerBuild["entry"]; | ||
| export const future: ServerBuild["future"]; | ||
| export const isSpaMode: ServerBuild["isSpaMode"]; | ||
| export const prerender: ServerBuild["prerender"]; | ||
| export const publicPath: ServerBuild["publicPath"]; | ||
| export const routeDiscovery: ServerBuild["routeDiscovery"]; | ||
| export const routes: ServerBuild["routes"]; | ||
| export const ssr: ServerBuild["ssr"]; | ||
| export const unstable_getCriticalCss: ServerBuild["unstable_getCriticalCss"]; | ||
| } |
59 changes: 59 additions & 0 deletions
59
unstable_rsc-framework-mode/.react-router/types/app/+types/root.ts
This file contains hidden or 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,59 @@ | ||
| // Generated by React Router | ||
|
|
||
| import type { GetInfo, GetAnnotations } from "react-router/internal"; | ||
|
|
||
| type Module = typeof import("../root.js") | ||
|
|
||
| type Info = GetInfo<{ | ||
| file: "root.tsx", | ||
| module: Module | ||
| }> | ||
|
|
||
| type Matches = [{ | ||
| id: "root"; | ||
| module: typeof import("../root.js"); | ||
| }]; | ||
|
|
||
| type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }, true>; | ||
|
|
||
| export namespace Route { | ||
| // links | ||
| export type LinkDescriptors = Annotations["LinkDescriptors"]; | ||
| export type LinksFunction = Annotations["LinksFunction"]; | ||
|
|
||
| // meta | ||
| export type MetaArgs = Annotations["MetaArgs"]; | ||
| export type MetaDescriptors = Annotations["MetaDescriptors"]; | ||
| export type MetaFunction = Annotations["MetaFunction"]; | ||
|
|
||
| // headers | ||
| export type HeadersArgs = Annotations["HeadersArgs"]; | ||
| export type HeadersFunction = Annotations["HeadersFunction"]; | ||
|
|
||
| // middleware | ||
| export type MiddlewareFunction = Annotations["MiddlewareFunction"]; | ||
|
|
||
| // clientMiddleware | ||
| export type ClientMiddlewareFunction = Annotations["ClientMiddlewareFunction"]; | ||
|
|
||
| // loader | ||
| export type LoaderArgs = Annotations["LoaderArgs"]; | ||
|
|
||
| // clientLoader | ||
| export type ClientLoaderArgs = Annotations["ClientLoaderArgs"]; | ||
|
|
||
| // action | ||
| export type ActionArgs = Annotations["ActionArgs"]; | ||
|
|
||
| // clientAction | ||
| export type ClientActionArgs = Annotations["ClientActionArgs"]; | ||
|
|
||
| // HydrateFallback | ||
| export type HydrateFallbackProps = Annotations["HydrateFallbackProps"]; | ||
|
|
||
| // Component | ||
| export type ComponentProps = Annotations["ComponentProps"]; | ||
|
|
||
| // ErrorBoundary | ||
| export type ErrorBoundaryProps = Annotations["ErrorBoundaryProps"]; | ||
| } | ||
62 changes: 62 additions & 0 deletions
62
unstable_rsc-framework-mode/.react-router/types/app/routes/+types/home.ts
This file contains hidden or 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,62 @@ | ||
| // Generated by React Router | ||
|
|
||
| import type { GetInfo, GetAnnotations } from "react-router/internal"; | ||
|
|
||
| type Module = typeof import("../home.js") | ||
|
|
||
| type Info = GetInfo<{ | ||
| file: "routes/home.tsx", | ||
| module: Module | ||
| }> | ||
|
|
||
| type Matches = [{ | ||
| id: "root"; | ||
| module: typeof import("../../root.js"); | ||
| }, { | ||
| id: "routes/home"; | ||
| module: typeof import("../home.js"); | ||
| }]; | ||
|
|
||
| type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }, true>; | ||
|
|
||
| export namespace Route { | ||
| // links | ||
| export type LinkDescriptors = Annotations["LinkDescriptors"]; | ||
| export type LinksFunction = Annotations["LinksFunction"]; | ||
|
|
||
| // meta | ||
| export type MetaArgs = Annotations["MetaArgs"]; | ||
| export type MetaDescriptors = Annotations["MetaDescriptors"]; | ||
| export type MetaFunction = Annotations["MetaFunction"]; | ||
|
|
||
| // headers | ||
| export type HeadersArgs = Annotations["HeadersArgs"]; | ||
| export type HeadersFunction = Annotations["HeadersFunction"]; | ||
|
|
||
| // middleware | ||
| export type MiddlewareFunction = Annotations["MiddlewareFunction"]; | ||
|
|
||
| // clientMiddleware | ||
| export type ClientMiddlewareFunction = Annotations["ClientMiddlewareFunction"]; | ||
|
|
||
| // loader | ||
| export type LoaderArgs = Annotations["LoaderArgs"]; | ||
|
|
||
| // clientLoader | ||
| export type ClientLoaderArgs = Annotations["ClientLoaderArgs"]; | ||
|
|
||
| // action | ||
| export type ActionArgs = Annotations["ActionArgs"]; | ||
|
|
||
| // clientAction | ||
| export type ClientActionArgs = Annotations["ClientActionArgs"]; | ||
|
|
||
| // HydrateFallback | ||
| export type HydrateFallbackProps = Annotations["HydrateFallbackProps"]; | ||
|
|
||
| // Component | ||
| export type ComponentProps = Annotations["ComponentProps"]; | ||
|
|
||
| // ErrorBoundary | ||
| export type ErrorBoundaryProps = Annotations["ErrorBoundaryProps"]; | ||
| } |
This file contains hidden or 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,65 @@ | ||
| # Welcome to React Router! (Experimental RSC) | ||
|
|
||
| ⚠️ **EXPERIMENTAL**: This template demonstrates React Server Components with React Router. This is experimental technology and not recommended for production use. | ||
|
|
||
| A modern template for exploring React Server Components (RSC) with React Router, powered by Vite. | ||
|
|
||
| ## Features | ||
|
|
||
| - 🧪 **Experimental React Server Components** | ||
| - 🚀 Server-side rendering with RSC | ||
| - ⚡️ Hot Module Replacement (HMR) | ||
| - 📦 Asset bundling and optimization with Vite | ||
| - 🔄 Data loading and mutations | ||
| - 🔒 TypeScript by default | ||
| - 🎉 TailwindCSS for styling | ||
| - 📖 [React Router docs](https://reactrouter.com/) | ||
| - 📚 [React Server Components guide](https://reactrouter.com/how-to/react-server-components) | ||
|
|
||
| ## 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 | ||
| ``` | ||
|
|
||
| ## Running Production Build | ||
|
|
||
| Run the production server: | ||
|
|
||
| ```bash | ||
| npm start | ||
| ``` | ||
|
|
||
| ## Understanding React Server Components | ||
|
|
||
| Learn more about React Server Components with React Router in our [comprehensive guide](https://reactrouter.com/how-to/react-server-components). | ||
|
|
||
| ## 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 hidden or 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,15 @@ | ||
| @import "tailwindcss"; | ||
|
|
||
| @theme { | ||
| --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif, | ||
| "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; | ||
| } | ||
|
|
||
| html, | ||
| body { | ||
| @apply bg-white dark:bg-gray-950; | ||
|
|
||
| @media (prefers-color-scheme: dark) { | ||
| color-scheme: dark; | ||
| } | ||
| } |
This file contains hidden or 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,73 @@ | ||
| import { | ||
| isRouteErrorResponse, | ||
| Links, | ||
| Meta, | ||
| Outlet, | ||
| ScrollRestoration, | ||
| } from "react-router"; | ||
|
|
||
| import type { Route } from "./+types/root"; | ||
| import "./app.css"; | ||
|
|
||
| export const links: Route.LinksFunction = () => [ | ||
| { rel: "preconnect", href: "https://fonts.googleapis.com" }, | ||
| { | ||
| rel: "preconnect", | ||
| href: "https://fonts.gstatic.com", | ||
| crossOrigin: "anonymous", | ||
| }, | ||
| { | ||
| rel: "stylesheet", | ||
| href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap", | ||
| }, | ||
| ]; | ||
|
|
||
| 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 /> | ||
| </body> | ||
| </html> | ||
| ); | ||
| } | ||
|
|
||
| export default function App() { | ||
| return <Outlet />; | ||
| } | ||
|
|
||
| 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="container p-4 pt-16 mx-auto"> | ||
| <h1>{message}</h1> | ||
| <p>{details}</p> | ||
| {stack && ( | ||
| <pre className="overflow-x-auto p-4 w-full"> | ||
| <code>{stack}</code> | ||
| </pre> | ||
| )} | ||
| </main> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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,13 @@ | ||
| import type { Route } from "./+types/home"; | ||
| import { Welcome } from "../welcome/welcome"; | ||
|
|
||
| export function meta({}: Route.MetaArgs) { | ||
| return [ | ||
| { title: "New React Router App" }, | ||
| { name: "description", content: "Welcome to React Router!" }, | ||
| ]; | ||
| } | ||
|
|
||
| export default function Home() { | ||
| return <Welcome />; | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.