Bye bye create-react-app, Get started with React using Vite.js
Are you tired of using create-react-app to create your React applications? Well, you’re not alone. In March 2021, the React team launched their new website with updated documentation, and they no longer recommend using create-react-app.
So, what should you use instead? One great option is Vite. Vite is a build tool that makes it easy to set up a new React project with minimal configuration. In this blog post, we’ll walk you through the steps to get started with Vite and show you how it can improve your React development experience.
Step 1: Install Vite
To get started with Vite, you need to have Node.js installed on your machine. Once you have Node.js installed, you can install Vite using the following command:
npm install -g vite
Step 2: Create a new vite?project
Creating a new React project with Vite is as simple as running a these command:
npm init vite
We need to add a project and package name, as demonstrated below:
We then need to select React as the framework and variant:
领英推荐
Step 3: Run your project
Once your project is created, you can start a development server with the following command:
cd my-react-app
npm install
npm run dev
This command will start a development server, and you can begin building your React application right away.
Step 4: Build your project for production
When you’re ready to build your React application for production, you can use the following command:
npm run build
This command will create a production-ready build of your React application in the?dist?directory.
Conclusion
If you’re looking for a faster, more streamlined way to create your React applications, give Vite a try. It’s easy to set up and can significantly improve your development experience. So, say goodbye to create-react-app and hello to Vite. Happy coding???!
Source of this post: apoorveverma.com
Task Card Owner / AMT
1 年This was such a straightforward answer. Thanks!
Software Engineer @ Turing | Google Services - LLM Node / React Engineer | Docker | TypeScript | Python
1 年Vite still not idle for some cases. For small apps, vite is okay. But for a large scale app vite is not being recommended.
Customer Success Professional and Frontend Developer with over 20 years of proven success in enhancing customer satisfaction across diverse industries.
1 年Hello - thanks for this article, very interesting. I have found that if you close your project down and want to restart it the next day you have to run all three commands for it to restart and not just the "npm run dev" which was intuitive for me after having used create-react-app in the past. Just thought it was worth mentioning in case there are others as well as me having problems restarting a project. Happy coding and keep up the good work ??
Software Engineer
1 年Great article, thank you.