Demo: The hosted demo at
react-starter.mcshinsky.netis currently offline (DNS removed 2026-11). See Deploy below to restore it, or run locally:npm install && npm run dev.
Production-ready, opinionated Vite + React 19 + TypeScript starter with Tailwind CSS 4, TanStack Query, Vitest, and Storybook 8. Built for teams shipping real products — not hello-world demos.
| Concern | create-vite |
Typical Starter | react-starter |
|---|---|---|---|
| Routing | ❌ Manual | ✅ Often | ✅ React Router 7, lazy routes, Suspense |
| Server state | ❌ Manual | ✅ TanStack Query 5, pre-configured provider | |
| Env validation | ❌ Manual | ✅ Zod schema, fails fast at boot | |
| Error boundaries | ❌ Manual | ❌ Rarely | ✅ Resettable boundary wrapping router |
| Feature folders | ❌ Flat | ✅ Enforced: features/, shared/, app/ |
|
| Testing | ✅ Vitest + RTL + jsdom, coverage gates | ||
| Storybook | ❌ Manual | ❌ Rarely | ✅ Pre-wired with Vite, docs + test addons |
| Multi-env config | ❌ Manual | ✅ .env.[mode] + Zod, 4 envs included |
|
| Path aliases | ❌ Manual | ✅ @/, @features/, @shared/ pre-configured |
TL;DR: You get ~40 hours of "set up the boring stuff right" work done for you. Fork → npm run dev → build features.
# 1. Clone and install
git clone https://github.com/michaelmcshinsky/react-starter my-app
cd my-app
npm install
# 2. Configure environment (pick one)
cp .env.development.example .env # local API on localhost
# cp .env.staging.example .env # staging API
# cp .env.production.example .env # production API
# 3. Start developing
npm run devThat's it. Open http://localhost:5173 — you have a running app with routing, server state, env validation, error boundaries, and a test suite.
src/
app/ # App shell: router, providers, global styles, error boundary
features/ # Feature modules — one folder per feature (home, about, auth, etc.)
home/ # components/, hooks/, api.ts, types.ts, index.ts (public API)
about/
shared/ # Cross-cutting: config (Zod env), providers, UI primitives, utilities
test/ # Test setup, utilities, custom render
| Decision | Rationale |
|---|---|
| Feature folders | Colocates route-level code with its components, hooks, types, and tests. Scales better than pages/ + components/ split as features grow. |
Path aliases (@/, @features/, @shared/) |
Eliminates ../../../ imports; makes refactoring safe; works in Vitest + Storybook + Vite identically. |
Route-level code splitting (React.lazy + Suspense) |
Default for every feature route. Keeps initial bundle small; loading UX handled by shared Suspense fallback. |
| Error boundary wrapping router | Catches render errors in any route, shows resettable fallback, logs to error service. Prevents white-screen crashes. |
Zod-validated import.meta.env |
Fails at boot (not runtime) if required vars missing or malformed. Type-safe env object everywhere via shared/config. |
| TanStack Query as server-state layer | Separates server state from client state. Devtools, caching, deduping, retries, prefetching — all configured once in shared/providers. |
Tailwind CSS 4 via @tailwindcss/vite |
Zero-config, lightning-fast, native Vite integration. No PostCSS config needed. |
| Vitest + Testing Library + jsdom | Fast, React-native testing. Tests compose providers (QueryClient, MemoryRouter) via small local helpers. |
- Home — Hero, feature grid, navigation to About
- About — Static content page demonstrating lazy route loading
- Error Boundary — Wraps the router; resettable fallback on render errors (see the
WithErrorStorybook story)
These are conventions to copy, not shipped files — create them in the locations shown when you need them.
| Pattern | Suggested Location | Use For |
|---|---|---|
| Auth stub | features/auth/ (create it) |
Login/register forms, protected routes, token refresh |
| Data table | shared/components/DataTable.tsx |
Sortable, filterable, paginated server-driven tables |
| Zod form | shared/components/ZodForm.tsx |
Type-safe forms with schema validation + error display |
| Error handling | shared/lib/errors.ts |
ApiError, ValidationError, NotFoundError classes + handleError helper |
| API client | shared/api/client.ts |
Typed fetch wrapper with interceptors, auth, base URL from env |
Pro tip: Run
npm run storybookto browse all shared components in isolation with controls and docs.
| Layer | Choice | Version |
|---|---|---|
| Build | Vite | 6 |
| UI | React + TypeScript (strict) | 19 |
| Routing | React Router (lazy routes) | 7 |
| Styling | Tailwind CSS (@tailwindcss/vite) |
4 |
| Server State | TanStack Query | 5 |
| Config Validation | Zod | 4 |
| Testing | Vitest + Testing Library + jsdom | 5 |
| Component Explorer | Storybook | 8 |
| Linting | ESLint flat config + typescript-eslint | 10 |
| Package Manager | npm (works with pnpm/yarn) | — |
| Command | Description |
|---|---|
npm run dev |
Start Vite dev server (HMR, env validation) |
npm run build |
Typecheck (tsc --noEmit) + production build |
npm run preview |
Preview production build locally |
npm test |
Run Vitest suite (watch mode) |
npm run test:run |
Run Vitest once (CI mode) |
npm run test:coverage |
Run tests with V8 coverage report |
npm run typecheck |
tsc --noEmit |
npm run lint |
ESLint (flat config) |
npm run storybook |
Storybook dev server (port 6006) |
npm run build-storybook |
Static Storybook build to storybook-static/ |
Vite loads .env.[mode] automatically based on --mode flag. All VITE_* keys are validated by Zod at boot in shared/config/env.ts.
| File | Purpose |
|---|---|
.env.development.example |
Local dev — API on http://localhost:3000 |
.env.staging.example |
Staging — API on https://api-staging.example.com |
.env.production.example |
Production — API on https://api.example.com |
# Development (default)
npm run dev
# Staging
npm run dev -- --mode=staging
# Production build
npm run build -- --mode=productionRequired env vars (validated at boot):
VITE_API_URL=https://api.example.com
VITE_APP_TITLE=My App# 1. Create feature folder
mkdir -p src/features/my-feature/{components,hooks}
# 2. Add route (lazy-loaded) in src/app/App.tsx
{ path: '/my-feature', element: <LazyMyFeature /> }
# 3. Write components, hooks, types, API calls
# 4. Add tests in src/features/my-feature/__tests__/
# 5. Add stories in src/features/my-feature/*.stories.tsx- Create
src/features/auth/withLoginForm,RegisterForm,useAuthhook - Add
AuthProviderinshared/providers/AuthProvider.tsxwrappingQueryClientProvider - Protect routes with
<RequireAuth>wrapper component - Add token refresh logic in your API client (
shared/api/client.tsonce created)
The project ships with public/_redirects (SPA fallback), which Netlify and
Cloudflare Pages both honor automatically.
npm run build
# Deploy the dist/ folderCloudflare Pages (recommended — same provider as mcshinsky.net DNS):
- Pages project → connect this GitHub repo.
- Build command:
npm run build· Output directory:dist. - Custom domain: add
react-starter.mcshinsky.netunder the project's Custom domains; Cloudflare creates the DNS record automatically. - To serve Storybook at
/storybook: build it (npm run build-storybook→storybook-static/) and either deploy it as a second Pages project on a subdomain (e.g.storybook.react-starter.mcshinsky.net) or copystorybook-static/intodist/storybook/in a post-build step and add/storybook/* /storybook/index.html 200above the catch-all inpublic/_redirects.
Netlify:
netlify deploy --prod --dir=distafternpm run build, or connect the repo in the Netlify dashboard (build:npm run build, publish:dist).- Add
react-starter.mcshinsky.netas a custom domain in site settings.
Any static host (Vercel, GitHub Pages, Surge, S3+CDN): build, then upload
dist/; configure the host's SPA rewrite to index.html if it does not read
_redirects.
Docker
docker build -t my-app .
docker run -p 8080:80 my-app- Architecture & Decisions — Why feature folders, lazy routes, TanStack Query, and the error boundary; every major choice with tradeoffs (the previous hosted deep-dive article is offline)
- Contributing — Branch strategy, commit conventions, PR requirements
- Security — Vulnerability reporting, dependency policy
Issues and PRs welcome! Please read CONTRIBUTING.md first. Key points:
- All changes require passing
typecheck,lint,test, andbuild - Feature work on branches; PRs target
main - Update stories/tests/docs alongside code
MIT © Michael McShinsky — see LICENSE for details.