# Bunjs with ExpressWebJs

Bun.js is a JavaScript runtime that is designed to be fast and efficient. By using Bun.js with ExpressWebJS, you can create web applications that are both fast and scalable. Bun.js can handle a large number of concurrent connections, and ExpressWebJS provides a variety of features that make it easy to develop and maintain scalable web applications.
For Bun installation, visit the installation page at Bun.sh
Once installation is complete, you need to install bun-types which is the Typescript definition for Bun's built-in APIs in your project directory as a dev dependency
bun add -d bun-types
Copied!
Then include "bun-types"
in the compilerOptions.types
in your tsconfig.json
:
{ "compilerOptions": { "types": ["bun-types"] } }
Copied!
Below is the suggested compilerOption to use in tsconfig.json
{ "extends": "./node_modules/expresswebjs-preset-ts/tsconfig.json", "compilerOptions": { "allowSyntheticDefaultImports": true, "esModuleInterop": true, "resolveJsonModule": true, "noUnusedLocals": true, "noPropertyAccessFromIndexSignature": true, "strictNullChecks": true, "useUnknownInCatchVariables": true, "experimentalDecorators": true, "forceConsistentCasingInFileNames": true, //Bun config "lib": ["ESNext"], "module": "esnext", "target": "esnext", "moduleResolution": "bundler", "moduleDetection": "force", "allowImportingTsExtensions": true, "noEmit": true, "composite": true, "strict": true, "downlevelIteration": true, "skipLibCheck": true, "jsx": "preserve", "allowJs": true, "types": [ "bun-types" // add Bun global ] } }
Copied!
Once that is done, you will need to update the script section in package.json
file
"scripts": { "start": "bun --hot run app.ts", "maker": "bun maker.ts" }
Copied!
Finally run bun install to install all dependencies.
bun install
Copied!
Once you are done installing all dependencies, you can run bun start
to start your application.
bun start
Copied!