This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Babel for Fast Refresh
- @vitejs/plugin-react-swc uses SWC for Fast Refresh
Make sure you have the following installed:
-
Clone the repository:
git clone https://github.com/your-username/your-repo.git cd your-repo -
Install dependencies:
npm install
or
yarn install
- run json-server :
npm run serveror
yarn server- Start the Vite development server:
npm run devor
yarn dev- After running the command, you should see an output like this:
VITE vX.X.X ready in Xms
➜ Local: http://localhost:5173/
➜ Network: use --host to exposeOpen http://localhost:5173 in your browser to see the application running.
This project uses a local JSON file (data/cities.json) as a mock API. To serve this file as an API:
-
Install JSON Server (if not already installed):
npm install -g json-server
-
Start the JSON Server:
json-server --watch data/cities.json --port 3001
This will start a local API server at:
http://localhost:3001/cities
-
You can now make API requests:
- Get all cities:
curl http://localhost:3001/cities
- Access it in the browser: http://localhost:3001/cities
- Get all cities:
To create a production-ready build, run:
npm run buildor
yarn buildThis will generate a dist/ folder with optimized assets.
Now you're all set! 🚀 Happy coding!