React app structure with Vite and TypeScript

Maya Patel Jan 2026
2 tabs
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'

export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
  server: {
    port: 5173,
    proxy: {
      '/api': {
        target: 'http://localhost:3000',
        changeOrigin: true,
      },
    },
  },
})
2 files · typescript, json Explain with highlit

Vite provides lightning-fast dev server startup and hot module replacement compared to Create React App. I scaffold React projects with TypeScript for type safety across the entire frontend. The folder structure separates concerns: components for reusable UI, pages for route-level components, hooks for custom hooks, services for API clients, and types for TypeScript definitions. I configure absolute imports via tsconfig.json so I can write import Button from '@/components/Button' instead of relative path hell. Environment variables prefixed with VITE_ are exposed to the client bundle. This structure scales well from small projects to large applications with dozens of developers.