DEV Community

Cover image for Creating a new React app in a few seconds
Kenneth Lum
Kenneth Lum

Posted on

Creating a new React app in a few seconds

There is a method to create a new React app quickly, much faster than create-react-app or by Next.js

The method is by Vite. Assuming you are using a recent version of npm (7 or above), the following steps will create a new React app in seconds:

npm create vite@latest myapp -- --template react
code .
cd myapp
npm i
npm run dev -- --open
Enter fullscreen mode Exit fullscreen mode

If you don't use Visual Studio Code or don't have the command line to start it already set up, then you can remove the line code . or replace it with a command line that will start your editor if you want.

You also can create an alias and put it in your .bashrc:

alias vitecreate='npm create vite@latest myapp -- --template react && code . && cd myapp && npm i && npm run dev -- --open'
Enter fullscreen mode Exit fullscreen mode

and then you can:

mkdir MyNewReactProject
cd MyNewReactProject
vitecreate
Enter fullscreen mode Exit fullscreen mode

and start doing development work right away. You can use codesandbox.com too, but if you want a local server running, together with your favorite IDE and being able to do git commits, you can use this Vite method.

If you want to play with the SWC (Speedy Web Compiler) template, you can use react-swc instead of react after the --template flag. For more information about different templates, see https://vitejs.dev/guide

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay