Skip to content

Boilerplate to get started with React Router 7 and Fastify

Notifications You must be signed in to change notification settings

simonsmith/react-router-fastify

Repository files navigation

React Router ❤️ Fastify

This is a simple boilerplate to get an application running using React Router 7 and Fastify

Get Started

  1. Clone the repository
  2. Install the packages with your favourite package manager (there is no lockfile by default, so choose whatever suits you)
  3. Run the development server with <package manager> run dev

Structure

client
├── components   # all your react components
├── routes       # react-router components + query files
├── styles       # any global styles
└── util         # things like queryClient
├── routes.ts
├── root.tsx
server
├── start.ts     # setup the server. Add any API routes, db connections etc in this dir
public
types            # global types accessible to all

One pattern utilised here is to integrate react-query with the clientLoader of each route, and then within the relevant page component like Home.

The logic for the queries in stored in a relevant <routeName>.queries.ts

Read more:

Commands

Command Action
npm install Installs dependencies
npm run dev Starts the vite development server
npm run build Builds the production site to ./build/
npm run format Formats files with Prettier
npm run check Runs all linter checks
npm run start Start the server with Node

Credit

Inspired by the excellent mcansh/remix-fastify examples

About

Boilerplate to get started with React Router 7 and Fastify

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published