Create a react app with bun

Want to use bun for your next react projects?

Install bun

First run the following command to check bun is installed or not

bun -v

If you don’t have bun installed then run the following command to install bun

curl ht…


This content originally appeared on DEV Community and was authored by Ashirbad Panigrahi

Want to use bun for your next react projects?

Install bun

First run the following command to check bun is installed or not

bun -v

If you don't have bun installed then run the following command to install bun

curl https://bun.sh/install | bash

Create a react app

Now run the following command to create a react app

bun create react [your-app-name]

It will create a new directory with the name of your app. To start the app run the following command

cd your-app-name
bun dev

Build production bundle for react app

By default bun does not ship with react-scripts so you need to install it first.

bun a react-scripts -d

Here we install it as a dev dependency.

Then run the following command to build the production bundle

bun react-scripts build

When you run the command above it will build the production bundle and it will be stored in the build directory.

Adding scripts to your package.json

We can add the following scripts to our package.json file

{
  "scripts": {
    "start": "bun dev",
    "build": "react-scripts build"
  }
}

Now we can run the following command to start the app

bun start

And we can run the following command to build the production bundle

bun run build

Bonus:

By default bun creates react app with javascript but we can easily use typescript by changing the file extension from .jsx to .tsx

Get Full Source Code In GitHub


This content originally appeared on DEV Community and was authored by Ashirbad Panigrahi


Print Share Comment Cite Upload Translate Updates
APA

Ashirbad Panigrahi | Sciencx (2022-07-16T02:11:25+00:00) Create a react app with bun. Retrieved from https://www.scien.cx/2022/07/16/create-a-react-app-with-bun/

MLA
" » Create a react app with bun." Ashirbad Panigrahi | Sciencx - Saturday July 16, 2022, https://www.scien.cx/2022/07/16/create-a-react-app-with-bun/
HARVARD
Ashirbad Panigrahi | Sciencx Saturday July 16, 2022 » Create a react app with bun., viewed ,<https://www.scien.cx/2022/07/16/create-a-react-app-with-bun/>
VANCOUVER
Ashirbad Panigrahi | Sciencx - » Create a react app with bun. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/07/16/create-a-react-app-with-bun/
CHICAGO
" » Create a react app with bun." Ashirbad Panigrahi | Sciencx - Accessed . https://www.scien.cx/2022/07/16/create-a-react-app-with-bun/
IEEE
" » Create a react app with bun." Ashirbad Panigrahi | Sciencx [Online]. Available: https://www.scien.cx/2022/07/16/create-a-react-app-with-bun/. [Accessed: ]
rf:citation
» Create a react app with bun | Ashirbad Panigrahi | Sciencx | https://www.scien.cx/2022/07/16/create-a-react-app-with-bun/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.