A modern, feature-rich starter template for React applications built with Vite, TypeScript, and TailwindCSS. This template provides a solid foundation for building scalable web applications with best practices and a well-organized project structure.
# Check if installed
npm -v
# or
yarn -v
git clone https://github.com/mrmendoza-dev/vite-react-template
cd vite-react-template
npm install
# or
yarn
.env
file in the root directory:VITE_PORT=3030
VITE_API_URL=http://localhost:3030
npm start
# or
yarn start
This will run:
npm run dev
# or
yarn dev
npm run server
# or
yarn server
npm run build
# or
yarn build
npm run preview
# or
yarn preview
react-vite-template/
├── public/ # Static assets and PWA files
│ ├── favicon/ # Favicon files
│ ├── images/ # Public images
│ ├── _redirects # Netlify redirects
│ └── robots.txt # SEO robots file
├── server/ # Backend server code
│ ├── routes/ # Express routes
│ └── utils/ # Server utilities
├── src/ # Frontend source code
│ ├── assets/ # Frontend assets
│ ├── components/ # React components
│ │ ├── common/ # Shared components
│ │ ├── layout/ # Layout components
│ │ └── ui/ # UI components (Shadcn)
│ ├── contexts/ # React contexts
│ ├── data/ # Static data
│ ├── hooks/ # Custom hooks
│ ├── lib/ # Utility libraries
│ ├── pages/ # Page components
│ ├── services/ # API services
│ ├── styles/ # CSS/SCSS files
│ ├── types/ # TypeScript type declarations
│ └── utils/ # Helper functions
└── docs/ # Documentation
Variable | Description | Required |
---|---|---|
VITE_PORT | Backend server port | Yes |
VITE_API_URL | API base URL | Yes |
useIsMobile
- Detect mobile screen sizeuseLocalStorage
- Persist data in localStorageuseModal
- Simple modal state managementuseFocus
- Auto-focus elementsuseInterval
- Safe interval hookThe application can be deployed using:
npm run build
dist
dist
This template includes PWA capabilities through Vite PWA plugin:
The template uses Shadcn UI for component styling. To customize:
src/styles/index.css
cn()
utility function to compose classesMIT