Getting Started
bunito is a small Bun-first TypeScript framework for applications built from modules, providers, lifecycle hooks, configuration, logging, and HTTP controllers.
The framework is intentionally split into focused packages. Start with @bunito/bunito for application code, then add feature packages such as @bunito/http when the application needs them.
Install The CLI
The preferred entrypoint for bunito projects is the CLI.
bun install --global @bunito/cliThe CLI is still under active development. It is already used by the example workspace, but project scaffolding and day-to-day workflows may change. For the most reliable starting point today, continue with the manual setup below and the step-by-step tutorials.
Manual Setup
Create a Bun project:
mkdir my-bunito-app
cd my-bunito-app
bun init -yInstall the core package:
bun add @bunito/bunitoConfigure TypeScript by extending the bunito config:
{
"extends": "@bunito/bunito/tsconfig.json"
}Create src/main.ts:
import { App, Logger, LoggerModule, Provider } from '@bunito/bunito';
@Provider({
injects: [Logger],
})
class HelloService {
constructor(private readonly logger: Logger) {
this.logger.setContext(HelloService);
}
hello(): string {
this.logger.debug('hello() called');
return 'Hello from bunito';
}
}
const app = await App.create({
imports: [LoggerModule],
providers: [HelloService],
});
const helloService = await app.resolve(HelloService);
console.log(helloService.hello());
await app.start();
await app.shutdown();Add a bunito.json file. The CLI reads this file to discover runnable apps:
{
"apps": {
"main": {
"entry": "src/main.ts"
}
}
}Add scripts to package.json:
{
"scripts": {
"start": "bunito start main"
}
}Run the app:
bun run start