DEV Community

Devang Tomar
Devang Tomar

Posted on • Originally published at on

Bun: A brand-new, lightning-quick JavaScript runtime 🌭

Bun logo

What is Bun? 🤔

Bun is built on Zig and has the ability to transpile, set up, and run TypeScript and JavaScript projects. It is a full utility since it also functions as a package manager. Thats why its referred to as all-in-bun. This has been made possible via the usage of Zig, a dated programming language that was initially created for video games.

Notably, a bun produces another bun.lockb file, which is not comparable to a standard typical yarn.lock or package-lock.json file. The lock file that goes along with it is produced in binary. Exactly why? due to performance-related factors. This can make it difficult to track changes in common PRs.

Performance 🏃

People now refer to it as blazingly fast instead of just fast.

What could be better than a detailed examination of some of its benchmarks in comparison to NodeJs and Deno:

Comparison of Reacts server-side rendering :

SSR render comparison

In SSR of React, Bun is unquestionably more than 3 times faster 🚀 in handling http requests.

Comparison in terms of Hashing :

Hashing render comparison

Bun has a staggering 6.3 times higher average 😮 query throughput than deno and nodeJs, respectively.


Numerous Node.js and Web APIs, such as fs, path, Buffer, and others, are natively supported by Bun. This means that many npm packages already in use will be run by bun.

Bun Node Deno meme

Through improved, more user-friendly tooling, Bun wants to run the majority of JavaScript outside of browsers, increasing infrastructure complexity and speed.

  • TypeScript with JSX? It will work. (even .tsconfig support).
  • Bun loads.env files for you automatically.
  • Node modules? No issue.
  • There are built-in web APIs like fetch and WebSocket
  • Run a test? We possess it. Its also quick.
  • Package manager? It soars.

Getting started đŸŽŦ

Run this install script in your terminal to install Bun. From GitHub, Bun is downloaded.

curl | bash

Enter fullscreen mode Exit fullscreen mode

Bun install

Create a react app 🔨

Run the command below to create a react app right away.

bun create react bun-app

Enter fullscreen mode Exit fullscreen mode

react app bun

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

Enter fullscreen mode Exit fullscreen mode

bun dir

bun dev

Build production bundle for react app 🏗

React-scripts is not included by default with Bun, therefore you must first install it.

bun a react-scripts -d

Enter fullscreen mode Exit fullscreen mode

It is set up in this place as a dev dependency.

Run the subsequent command to create the production bundle after that.

bun react-scripts build

Enter fullscreen mode Exit fullscreen mode

bun react app

The production bundle will be created when you issue the aforementioned command, and it will be saved in the build directory.

Adding scripts to your package.json 📜

The scripts listed below can be included in our package.json file.

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

Enter fullscreen mode Exit fullscreen mode

To launch the app, issue the following command.

bun start

Enter fullscreen mode Exit fullscreen mode

And to create the production bundle, we may issue the following command.

bun run build

Enter fullscreen mode Exit fullscreen mode


Bonus 💰

Bun builds react apps by default with javascript, however typescript can be used by simply changing the file extension from .jsx to .tsx.

Conclusion 💭

Its admirable that Bun.js has lofty goals for the future. Although it is currently too early to declare that it will replace Node.js, that is its intended replacement. Although Bun.js performs insanely, it tries to replace a lot of tools at once, which puts a heavy pressure on the Bun.js developers. Additionally, Zig is not a very well-known programming language, making it difficult, in my opinion, to find a contributor.

It will take years for Bun.js to mature and become a technology that we can use in production applications because it is still too new and immature. Even so, it has a lot of potential.

Github URL for the app đŸ’ģ

GitHub - devangtomar/bun-app

_Contribute to devangtomar/bun-app development by creating an account on

Lets connect and chat! Open to anything under the sun 🏖🍹

Twitter : devangtomar7

LinkedIn : devangtomar

Stackoverflow : devangtomar

Instagram : be_ayushmann

Medium : Devang Tomar

Top comments (0)