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 an ArrayBuffer to a Uint8Array
A
Instances of other typed arrays can be created similarly.
To create a typed array that only views a portion of the underlying buffer, pass the offset and length to the constructor.
See Docs > API > Utils for more useful utilities.
Uint8Array is a typed array, meaning it is a mechanism for viewing the data in an underlying ArrayBuffer.
const buffer = new ArrayBuffer(64);
const arr = new Uint8Array(buffer);
Instances of other typed arrays can be created similarly.
const buffer = new ArrayBuffer(64);
const arr1 = new Uint8Array(buffer);
const arr2 = new Uint16Array(buffer);
const arr3 = new Uint32Array(buffer);
const arr4 = new Float32Array(buffer);
const arr5 = new Float64Array(buffer);
const arr6 = new BigInt64Array(buffer);
const arr7 = new BigUint64Array(buffer);
To create a typed array that only views a portion of the underlying buffer, pass the offset and length to the constructor.
const buffer = new ArrayBuffer(64);
const arr = new Uint8Array(buffer, 0, 16); // view first 16 bytes
See Docs > API > Utils for more useful utilities.
Was this page helpful?
⌘I
