Setting up development tools
- Download and install Node.js. Details are found here.
- Optionally to automatically generate React code snippets in Visual Studio Code, search extensions for "react" and install the extension called "ES7+ React/Redux/React-Native snippets" by the publisher dsznajder.
Scaffolding a new project
- Run below command to create a new project say called myproject:
npm create vite@latest myproject - Select the framework: React
- Select the varient: JavaScript
- Select the linter: Oxlint
- Select "Yes" if
npm installandnpm run devshould run automatically. - If selected "No", run the following commands afterwards:
- To change to the correct directory:
cd myproject - To install node packages (project dependencies):
npm install - To start development server:
npm run dev
- To change to the correct directory:
- The URL to access the development server will appear on the terminal. Use a web browser and access that URL.
Opening inside an IDE
Open the generated myproject (say) directory from an IDE like Visual Studio Code.
To experiment, edit index.css, App.css and App.jsx while observing the results on the web browser.
Build the project
Run the below command to build the project:
npm run build
The output will be placed inside a directory called dist. This content can be uploaded to a web server. Note that opening the index.html file directly from a web browser (i.e. without serving from a web server) might not work.