Jehlani Luciano Logo

Bun

Instructions to use bun/bunx instead of npm/npx.

Bun Logobun
          
            # Bun Web Development Guidelines

## General Principles

- Always use `bun` and `bunx` instead of `npm` and `npx` for package management and script execution
- Leverage Bun's built-in bundler, test runner, and TypeScript support when possible
- Use Bun's native APIs for improved performance in web applications

## Package Management

- Use `bun install` for installing dependencies
- Use `bun add [package]` to add new dependencies
- Use `bun remove [package]` to remove dependencies
- Always commit `bun.lockb` to version control

## Scripts & Commands

- Run scripts with `bun run [script]` instead of `npm run [script]`
- Execute packages with `bunx [package]` instead of `npx [package]`
- Use `bun [file.js]` to run JavaScript/TypeScript files directly

## Testing

- Prefer Bun's built-in test runner (`bun test`) over Jest or other test frameworks
- Use `bun test --watch` for development
- Configure tests in `package.json` with the "test" field

## Web Development Features

- Leverage Bun's built-in `.env` support
- Use Bun's native fetch API for improved performance
- Consider Bun's built-in file system APIs for server-side operations
- For production web servers, use `bun --hot` for hot module reloading

## Framework Integration

- When using frameworks like React, Next.js, or Astro, check for Bun-specific optimizations
- Configure your build tools to work optimally with Bun
- Consider using Bun plugins when available

## Performance

- Take advantage of Bun's speed for faster development and build times
- Use Bun's native APIs over Node.js equivalents when possible for better performance
- Consider Bun's optimized SQLite integration for simple database needs