Start with Bun
Have You Heard About Bun?
You know, the NodeJS framework that claims to be faster—but that’s not its only advantage.
It offers ease of use for unit testing, TypeScript support, and a module management system that simplifies integrations.
Official Bun Website
As you might have guessed, Bun is a development framework designed to “replace” NodeJS.
Installing Bun
To get started, let’s install Bun.
On Linux and macOS, use the following command:
Here’s the output of the command:
Now, let’s run the exec
command and test bun --help
.
Screenshot of bun --help
:
Everything looks good!
Next, I’ll create a new folder named “bun-trd”:
Then, navigate to the folder:
Creating the Project
Now, we’ll create the project using bun init
:
You can see that Bun has generated a folder with all the necessary files for our project.
(Unlike NodeJS, it doesn’t create an index.js
file by default.)
In the package.json
, I’ll add the scripts
section, which allows us to run the index.ts
file containing a console.log
:
What is --hot
? Magic!
It’s an option that enables hot reload. No need to add nodemon
or other tools. :)
Finally, let’s run the project using bun run dev
:
And voilà, our project is running with hot reload, without any additional packages!
In the next part, we’ll see how to create an API with Bun.