Nugget 7: Create a React Project with Vite
To create your new app select or create a directory where this app will reside. You will need node, at least version 16. On my computer I am running v20.11.0.
Follow these steps. I have a Windows computer and I am using the Windows Command Prompt (cmd):
- npm create vite@latest. The tool will ask for a project name.
- Enter a project name and hit enter. Next, we need to select the framework.
- Using the Up/Down arrow keys select React. Next we select the development language.
- Using the Up/Down arrow keys select Typescript. That was my selection. I could have selected JavaScript over Typescript, however, Typescript has many advantages over JavaScript including:
- Static Typing: errors can be caught at compile time rather than at runtime.
- Compile Error Catching.
- Better support for Code Autocomplete & IntelliSense than JavaScript: Thanks to type information editors like VSCode can provide better autocompletion, navigation, and refactoring tools.
Easy! The project has been created, but to finish we need to follow the instructions on the screen. After running "npm run dev" your Vite server will start. Point your favorite bowser to the address indicated by the tool.
There is a better way to run the React-Vite project. If you are already running the project you can stop it by pressing the q and enter keys at the same time. I am using Visual Studio Code, therefore, from the same directory I typed code ., and that opens VSCode on the project I just created. Now open a terminal in VS Code and run the project with npm run dev.
You are done! Now start learning or build your killer app!
Comments
Post a Comment