Vite alone is enough for component work and static pages, but you still need a local development server or backend whenever your app depends on real API calls, login flows, file uploads, or production routing rules. Skip it, and code that looks fine in dev can fail on cookies, CORS, redirects, or 404 handling. This guide gives a practical rule for deciding when Vite is enough and when a separate local server still matters.
What you'll need
- A React app created with a Vite React template.
- A browser with developer tools for checking network requests, cookies, and route responses.
- A local backend, mock server, or API service for anything that depends on real request/response behavior.
- A proxy or CORS configuration when the frontend and backend use different origins.
- React Router if your app needs nested routes, route parameters, or query parameters.
- TanStack Query if your app fetches server data and needs caching or request deduping.
What Vite dev server already covers
Vite is a build tool and local dev server for modern web apps. In a scratch React app, it typically serves source files straight to the browser with native ES modules, then applies Hot Module Replacement so changed modules update without a full refresh. That is why Vite starts in seconds, not minutes, and why small UI edits feel instant.
What React gets for free in a scratch app
React is a UI library for building interfaces, and many new projects begin as client-only single-page apps. That setup works well for local component work, static content, and route state that stays inside the browser. The common Vite React template gives you the starter files, alias-friendly config, and a fast feedback loop.
React Router and TanStack Query fit that model well. React Router handles nested routes, route parameters, and query parameters. TanStack Query helps cache server data and avoid request waterfalls. But both still depend on where the data comes from and how the browser reaches it.
Where a client-only setup starts to fall short
A client-only Vite server usually does not match production behavior by default. It does not reproduce auth cookies, backend redirects, or path rewriting unless you add those pieces yourself. It also does not stand in for SSR, SSG, or React Server Components, which are framework-level features rather than things a plain Vite app gives you for free.
Suppose a dashboard loads fine from mocked JSON, but the real API sets an httpOnly session cookie and redirects unauthenticated users to /login. The UI may look correct while the browser silently drops the cookie because the request origin or cookie settings do not match production.
Do I still need a local development server?
Yes, when your React app must behave like it will in production. Vite is often enough for isolated UI work, but a local backend or production-like server becomes useful when the app needs live APIs, cookie-based auth, file uploads, or route handling that depends on server responses.
A common first-timer mistake is treating “the page renders” as proof that the app is ready. Rendering proves only that the browser can load the bundle. It does not prove that POST requests, redirects, CSRF checks, or deep links will work after deployment.
Use this rule
- Check the dependency. If the feature depends only on props, local state, or static files, Vite alone is usually enough.
- Check the request path. If the feature needs fetch, cookies, uploads, or redirects, add a local backend or production-like server.
- Check the route behavior. If direct loads of /settings/123 or /search?q=term must work, test with real route handling, not only client navigation.
When is Vite's dev server enough for React development?
Vite's dev server is often enough for static UI work, mocked data, and client-only routing. It is the right choice when you want fast module updates, local component isolation, and browser-only behavior without depending on server state. In that zone, native ES modules and HMR solve the main feedback problem.
Static UI work without backend dependencies
Use Vite alone for forms, modals, layout changes, typography, and component states driven by local fixtures. If the feature does not need a real API shape, a local backend adds noise instead of value. Vite's server already gives you quick reloads and direct source loading.
Mocked data and isolated components
Mocked responses are fine for pure presentation work. They help when the API contract is still moving or the backend is not ready. Keep the mock close to the expected payload shape, though, or TanStack Query and your UI may fit the mock instead of the real response.
Simple routing with no auth or cookie state
Client-only route changes are a good fit for Vite alone. If React Router is handling nested routes and query parameters without any server-side decisions, the dev server can serve the app and let the router take over after load. That stops being enough when direct URL visits need server cooperation.
When do React apps need a local backend server?
React apps need a local backend server when the browser is no longer the whole story. Real APIs, auth flows, uploads, and production route rules all introduce server behavior that Vite does not simulate by itself. A local backend, or a server that mirrors production paths, closes that gap.
API integration and request shape changes
If the frontend depends on /api/dinosaurs, user search, pagination, or a changing JSON contract, run a local backend or API stub with the real endpoints. The Deno tutorial that uses Vite starts the app with deno run dev, serves it on localhost, adds CORS middleware, and includes both /api/dinosaurs and a second detail route. That is the kind of setup that catches request mismatches early.
Auth, cookies, and same-site behavior
Use a backend server whenever login state depends on cookies, sessions, or redirects. Cookie attributes, same-site rules, and origin matching can change whether the browser sends credentials at all. Vite alone cannot reproduce those conditions unless you add a backend that sets and reads the same headers.
Route rewriting, uploads, and service worker checks
Production-like route rewriting often matters when refreshes on nested URLs must return the app shell or a server-rendered page, not a 404. File uploads need server endpoints that accept multipart bodies. Service worker behavior also belongs in this bucket, because caching and offline fallbacks depend on the serving path and response headers, not just on the React code.
How do I decide between Vite, a dev server, and production-like local setup?
Choose Vite only for frontend work that can live entirely in the browser. Choose a production-like local setup when route rewriting, cookie scope, static asset paths, or service worker behavior must match deployment closely.
Decision matrix
| Scenario | Vite dev server only | Needs local backend server | Needs proxy/CORS setup | Why it matters |
|---|---|---|---|---|
| Static marketing pages | Yes | No | No | Direct source loading is enough; check only layout, copy, and responsive breakpoints. |
| Reusable components in Storybook-like isolation | Yes | No | No | Failure shows up as broken props, missing assets, or state resets after HMR. |
| Mocked CRUD screens | Mostly | Optional | No | Useful for UI flow, but real validation, status codes, and latency are still untested. |
| Live API integration | No | Yes | Often | Wrong base URLs, response formats, and error paths usually appear here first. |
| Cookie-based login | No | Yes | Often | Same-site rules and credentialed requests can fail even when the UI looks correct. |
| React Router deep links | Sometimes | Often | Maybe | Direct refresh on /users/42 or /search?q=term needs the server to return the app or the right page. |
| File uploads and previews | No | Yes | Sometimes | Multipart handling, size limits, and public asset URLs can differ from local mocks. |
| Service worker or asset-path checks | No | Yes | Sometimes | Cache scope, path rewrites, and offline fallbacks need a server shape close to production. |
Failure-case checklist by scenario:
- Static marketing pages: broken image paths, wrong font loading, client-only links that 404 on refresh.
- Reusable components: state resets after edits, missing context providers, asset imports that fail under alias rules.
- Mocked CRUD screens: mock returns 200 for every request, so error states and retries never get exercised.
- Live API integration: response shape drift, 401 handling, pagination headers, and query-string encoding bugs.
- Cookie-based login: credentials not sent, SameSite blocks the cookie, redirect loop after sign-in.
- React Router deep links: server returns 404 on refresh, nested route params fail, query state disappears on reload.
- File uploads and previews: upload endpoint path differs, file size limit differs, returned asset URL cannot be loaded.
- Service worker or asset-path checks: cached shell masks a broken deployment path, offline fallback never matches production.
Common mistakes
One common mistake is using Vite and a fake JSON file for everything, then discovering that the real backend expects a different method, header, or response code. Another is adding a proxy without deciding whether the backend also needs CORS, because proxies solve browser origin checks only in the local path you configure.
Say your app works at / but fails at /admin/users/17 after refresh. That usually means the local server is not rewriting unknown paths to the app shell, or it is serving the wrong file. The fix is server-side route fallback, not another React Router rule.
If that didn't work, try this next:
- Switch to a real backend. Add the API endpoint and auth flow locally before changing the frontend again.
- Enable proxy or CORS. If the frontend and API use different origins, configure one clear path and retest cookies and headers.
- Mirror production routing. Add route fallback, asset-path checks, and reload-on-deep-link behavior that match deployment.
Prevention: keep one local path that behaves like deployment for API calls, auth, and refreshes. That makes failures obvious before the app reaches a real server.
Frequently asked questions
Do I still need a local development server for a React app?
Yes, when your app depends on server behavior. A plain Vite dev server is fine for UI-only work, but a local backend is still useful for cookie auth, uploads, API errors, and redirects. If the browser must talk to something real, keep that path local.
When do React apps need a traditional local server instead of Vite?
Use a local server when the app must verify auth cookies, route fallback, file uploads, or backend response codes. Those behaviors sit outside a frontend-only dev server. If production behavior changes with origin or path, a server is part of the test.
Can I build a React app without a local development server?
You can build a frontend prototype without one, especially if the app is static or fully mocked. But the moment the app needs real data, login, or server routes, you need at least one backend endpoint or proxy target. Otherwise, production differences stay hidden.
What problems does a local server solve that Vite does not?
It covers request routing, cookie scope, auth redirects, upload handling, and path rewriting. Vite handles source delivery and HMR well, but it does not reproduce all server decisions by default. That gap is where many late-stage bugs come from.