# react-native-quick-base64

> A native implementation of base64 in C++ for React Native

Latest version **3.0.1** (published 2026-07-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-quick-base64
pnpm add react-native-quick-base64
yarn add react-native-quick-base64
bun add react-native-quick-base64
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2026-07-08 |
| First published | 2021-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Takuya Matsuyama |
| Maintainers | craftzdog |
| Keywords | react-native, ios, android |

## Links

- npm: https://www.npmjs.com/package/react-native-quick-base64
- Repository: https://github.com/craftzdog/react-native-quick-base64
- Homepage: https://github.com/craftzdog/react-native-quick-base64#readme
- Issues: https://github.com/craftzdog/react-native-quick-base64/issues
- npm.io page: https://npm.io/package/react-native-quick-base64

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 3.0.1 (latest) — 2026-07-08
- 3.0.0 — 2026-05-08
- 2.2.2 — 2025-09-01
- 2.2.1 — 2025-07-22
- 2.2.0 — 2025-05-28
- 2.1.2 — 2024-04-25
- 2.1.1 — 2024-04-11
- 2.1.0 — 2024-04-03
- 2.0.8 — 2023-12-08
- 2.0.7 — 2023-07-26
- 2.0.6 — 2023-05-01
- 2.0.5 — 2022-07-22
- 2.0.4 — 2022-07-22
- 2.0.3 — 2022-07-05
- 2.0.2 — 2022-01-22
- … 9 more at https://npm.io/package/react-native-quick-base64/versions

## README

# react-native-quick-base64

A blazing fast, native Base64 implementation for React Native using C++ and JSI.

This library is ~30x faster than [base64-js](https://github.com/beatgammit/base64-js).
Try the benchmarks in the [example](./example) app.

![benchmark](./docs/benchmark.png)

---

## Features

- ⚡ Native C++/JSI implementation for maximum performance
- 🧠 Automatically installs its JSI bindings at runtime
- 🧩 Drop-in replacement for `base64-js` with matching API
- 🔒 No additional native setup or linking required

---

## Installation

```bash
npm install react-native-quick-base64
```

> [!IMPORTANT]
> **Requires the New Architecture.** Version `3.0.0`+ is a pure C++ TurboModule and only registers when the app runs with React Native's New Architecture enabled:
>
> - Bare React Native: `newArchEnabled=true` (default on RN 0.76+; forced on 0.85+).
> - Expo: SDK 54+ (New Architecture is default), or SDK 53 with New Architecture explicitly enabled.
>
> On the Old Architecture you'll get `TurboModuleRegistry.getEnforcing(...): 'QuickBase64' could not be found`. Enable the New Architecture and rebuild (`cd android && ./gradlew clean`), or pin `react-native-quick-base64@2.2.2` to stay on the Old Architecture.

---

This module installs its native bindings automatically.
Simply importing the library is enough to activate the native backend.
Add it to your root entry point file or your first \_layout.tsx.

```js
import 'react-native-quick-base64' // triggers native JSI install to global namespace
```

You can also import individual helpers:

```tsx
import { fromByteArray, toByteArray } from 'react-native-quick-base64'
```

### Usage

```tsx
import { fromByteArray, toByteArray } from 'react-native-quick-base64'

const base64 = fromByteArray(new TextEncoder().encode('foo'))
const decoded = new TextDecoder().decode(toByteArray(base64))
```

---

## API

Compatible with [base64-js](https://github.com/beatgammit/base64-js).

### `byteLength(b64: string): number`

Returns the length of the byte array that corresponds to the base64 string.

### `toByteArray(b64: string, removeLinebreaks: boolean = false): Uint8Array`

Converts a base64 string into a Uint8Array.
If `removeLinebreaks` is `true`, all `\n` characters are removed first.

### `fromByteArray(uint8: Uint8Array, urlSafe: boolean = false): string`

Converts a byte array into a base64 string.
If `urlSafe` is `true`, the output uses a URL-safe base64 charset.

### `trimBase64Padding(str: string): string`

Removes trailing `=` or `.` padding from base64 or base64url-encoded strings.

> [!NOTE]
> **Breaking change** (#53):
> The `btoa`, `atob`, and `shim()` polyfills have been **removed**.
> Recent versions of **Hermes** provide `btoa` and `atob` natively in the JS runtime, so the polyfills are no longer needed.
> If you need string ⇄ base64 conversion, use `TextEncoder` / `TextDecoder` together with `fromByteArray` / `toByteArray` (see Usage below).

---

## Contributing

See the [contributing guide](https://github.com/craftzdog/react-native-quick-base64/blob/main/CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

---

## License

MIT © [Takuya Matsuyama](https://github.com/craftzdog)

---
_Source: https://npm.io/package/react-native-quick-base64 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
