Fix Bun Hot Reload Not Working

Is hot reloading not working in your bun.js project? This article gives you 3 potential fixes (from a real developer). First of all there are 2 ways you can hot reload code in your project: The first one, –hot, watches your files for changes and only reloads the content. It DOES NOT restart the bun … Read more

How to Use Files in Bun JS

Bun comes with its own modules for handling file read and writes. Let’s whip up a simple server that allows us to see this in action. Read an HTML File with Bun Initialise a new server and paste in the following code to your index.ts file: This will read an index.html file off disk and … Read more

How to Use Environment Variables in Bun JS

Bun JS, like all other server side tech, comes with the ability to read your environment variables. Environment variable files are read in a particular order though: Note that in item 2 (prod / dev / test) bun will first read the current environment variable -> NODE_ENV, to decide which one to select. You can … Read more

How to Create a Server in Bun JS

Note that these instructions are for installing on Mac. Linux or WSL on Windows. Native Windows is experimental at this point (2023) so best to avoid it for now. Open up a folder in VS Code where your project will live. Open up a terminal within VS Code and enter: This will install bun for … Read more