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
Top comments (28)
Can I also create next js app with bun?
Here it is the step by step guide for creating nextjs app with bun
dev.to/ashirbadgudu/lets-create-a-...
Yes you can I will post on this topic really soon.
Great article.
Does bun support other frameworks(I have svelte in mind) too?
Thanks again.
It is supports nextjs, react but I'm not sure about svelte but I will definitely look into it.
Thanks!
bun is on my „try next“ list. But i don’t understand why all package manager needs this „run“ word.
I want to execute scripts like:
bun dev
bun start
bun build
…
the reason is to avoid clashes or confusion with the cli commands. if you had
bun dev
, just by looking at the command you don't know if it's a command from the cli itself or a script from the package.json. withrun
you know what's a script and what's a cli command.Indeed
Yes I also want to see this, but for now you can use some certain commands in this way ex:
This is really cool thanks for this
Happy to hear it
Could I use npm packages?
Yes you can ex:
This is really great, how about bun for Vite? Once again, thank you.
why this happened?
Since bun can directly execute .ts and .tsx files we can use the typescript template to setup a typescript project instead of js:
bun create react-app my-app --template typescript
Spy Camera
 TECHNOVIEW 64GB Inbuilt Wireless Spy Camera WiFi Mini Camera Video Wireless CamerasWiFi Watch Live View Nanny Camera Users 1080P HD Cameras Video Audio Recording... -App V380 Pro.
device
buy now
Media
A hidden spy camera can shoot HD 1080P video and pixel photos. It is equipped with the latest CMOS sensor, it can show excellent image quality better than other cameras. Provide you with h-definition vision! Once your iPhone or Android phone is configured with router Wi-Fi (Only2.4GHz). Then you can view live video on the App remotely from anywhere in the world.
Hidden spy camera (1.1*1.1*1.1 inches) mini camera, and can be easily stored in various environments. Take videos and photos without attracting any attention. Small and exquisite equipment, it can be monitored even when power outages, HD at night, alarm reminder, easy to set up, HD picture quality, and mobile monitoring.
90° wide viewing angle helps you see more of what's happening, it doesn't emit light to attract any attention while shooting in the dark, it provides more accurate image quality than other cameras, and once the mini camera detects motion, it automatically saves the relevant video to SD card (64GB Sd Card Included).
Wireless camera built-in quality 300mAh rechargeable battery, this camera can work 60 Minutes without charging, 24/7 uninterrupted working while charging.The camera system Remote monitoring by APP (Only 2.4GHz WiFi), set the “WiFi Config” in the APP Device Setting for remote viewing. Just insert the SD card of 64GB (included with the camera) turn on recording and it can save the recording with the SD card.
ift.tt/toFIeby
July 24, 2022 at 12:46AM
Nowadays, the react template has been deprecated, the correct command should be:
Yes, I tried this one.
Some comments have been hidden by the post's author - find out more