Skip to content
Discussion options

You must be logged in to vote

I build exactly this setup (React + Vite frontend, Express + MongoDB backend), and for most apps I'd go with a separate frontend talking to an API.

Why:

  • Clean split: Express only returns JSON and React owns the UI. You can deploy them separately (e.g. frontend on Vercel, API on Render) and redeploy each on its own.
  • The same API can later serve a mobile app.
  • Simpler dev experience: Vite's dev server with HMR, and Express stays small.

Trade-offs: you have to handle CORS (or proxy /api through Vite in dev) and auth across origins. In my own app I use jsonwebtoken for user sessions: an auth middleware verifies the token, and if it's missing or invalid it responds with res.status(401) in one…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TahaAyati-DevLab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants