Skip to main content
Overview
Deployment
Runtime & Debugging
Utilities
Ecosystem & Frameworks
- Astro with Bun
- Discord.js with Bun
- Docker with Bun
- Drizzle with Bun
- Gel with Bun
- Elysia with Bun
- Express with Bun
- Hono with Bun
- Mongoose with Bun
- Neon Drizzle with Bun
- Neon Serverless Postgres with Bun
- Next.js with Bun
- Nuxt with Bun
- PM2 with Bun
- Prisma ORM with Bun
- Prisma Postgres with Bun
- Qwik with Bun
- React with Bun
- Remix with Bun
- TanStack Start with Bun
- Sentry with Bun
- SolidStart with Bun
- SSR React with Bun
- StricJS with Bun
- SvelteKit with Bun
- systemd with Bun
- Vite with Bun
- Upstash with Bun
HTTP & Networking
- HTTP Server with Bun
- Simple HTTP Server with Bun
- Fetch with Bun
- Hot reload an HTTP server
- Start a cluster of HTTP servers
- Configure TLS
- Proxy HTTP requests using fetch()
- Stream file response
- Upload files via HTTP using FormData
- Fetch with unix domain sockets
- Stream with iterators
- Server-Sent Events
- Stream with Node.js
Processes & System
Package Manager
- Add a dependency
- Add a dev dependency
- Add an optional dependency
- Add a peer dependency
- Add a Git dependency
- Add a tarball dependency
- Install with alias
- Workspaces with Bun
- Override the default npm registry
- Configure a scoped registry
- Azure Artifacts with Bun
- JFrog Artifactory with Bun
- Add a trusted dependency
- Generate a yarn-compatible lockfile
- Migrate from npm to bun
- Configure git to diff Bun's lockfile
- Install Bun in GitHub Actions
Test Runner
Runtime & Debugging
Module System
File System
- Read as string
- Read to Buffer
- Read to Uint8Array
- Read to ArrayBuffer
- Read JSON file
- Get MIME type
- Check file exists
- Watch directory
- Read as stream
- Write string to file
- Write Blob
- Write Response
- Append to file
- Incremental write
- Write stream
- Write to stdout
- Write file to stdout
- Copy file
- Delete file
- Delete files
- Delete directories
Utilities
HTML Processing
Binary Data
- ArrayBuffer to string
- ArrayBuffer to Buffer
- ArrayBuffer to Blob
- ArrayBuffer to Array
- ArrayBuffer to Uint8Array
- Buffer to string
- Buffer to ArrayBuffer
- Buffer to Blob
- Buffer to Uint8Array
- Buffer to ReadableStream
- Blob to string
- Blob to ArrayBuffer
- Blob to Uint8Array
- Blob to DataView
- Blob to ReadableStream
- Uint8Array to string
- Uint8Array to ArrayBuffer
- Uint8Array to Buffer
- Uint8Array to Blob
- Uint8Array to DataView
- Uint8Array to ReadableStream
- DataView to string
Binary Data
Convert a Uint8Array to an ArrayBuffer
A
The
See Docs > API > Binary Data for complete documentation on manipulating binary data with Bun.
Uint8Array is a typed array class, meaning it is a mechanism for viewing data in an underlying ArrayBuffer. The underlying ArrayBuffer is accessible via the buffer property.
const arr = new Uint8Array(64);
arr.buffer; // => ArrayBuffer(64)
The
Uint8Array may be a view over a subset of the data in the underlying ArrayBuffer. In this case, the buffer property will return the entire buffer, and the byteOffset and byteLength properties will indicate the subset.
const arr = new Uint8Array(64, 16, 32);
arr.buffer; // => ArrayBuffer(64)
arr.byteOffset; // => 16
arr.byteLength; // => 32
See Docs > API > Binary Data for complete documentation on manipulating binary data with Bun.
Was this page helpful?
⌘I
