# react-ts-base64-image-encoder

> A React Component that base64 encodes a image and return it as a string so[A[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C[C

Latest version **1.0.0** (published 2023-04-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-ts-base64-image-encoder
pnpm add react-ts-base64-image-encoder
yarn add react-ts-base64-image-encoder
bun add react-ts-base64-image-encoder
```

## Health

**Score 25/100 (F)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-04-22 |
| First published | 2023-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jonas Walden |
| Maintainers | unknown_monk |
| Keywords | image, uploader, next.js, typescript, image, uploader, base64, image, react, base64 |

## Links

- npm: https://www.npmjs.com/package/react-ts-base64-image-encoder
- Repository: https://github.com/UnknownMonk/React-Ts-Base64-Image-Encoder
- Homepage: https://https://github.com/UnknownMonk/React-Ts-Base64-Image-Encoder#readme
- Issues: https://https://github.com/UnknownMonk/React-Ts-Base64-Image-Encoder/issues
- npm.io page: https://npm.io/package/react-ts-base64-image-encoder

## Dependencies (2)

- [react](https://npm.io/package/react.md) ^16.8.0
- [react-dom](https://npm.io/package/react-dom.md) ^16.8.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2023-04-22

## README

# React-Ts-Base64-Image-Encoder

`react-ts-base64-image-encoder` is a simple utility package that converts uploaded files to Base64-encoded strings. It is available for use in TypeScript or JavaScript projects.

## Installation

To install `react-ts-base64-image-encoder`, run the following command:

```
npm install react-ts-base64-image-encoder
```

## Usage

```jsx
import FileBase64 from "react-ts-base64-image-encoder";
import {useState} from 'react';

function MyComponent() {
  interface Files {
    base64: any;
    // Add any other properties as needed
  }
  const [files, setFiles] = useState<Files>();
  const getFiles = (files: any) => {
    setFiles({ ...files });
  };

  return (
    <div>
      <FileBase64 multiple={false} onDone={(files) => getFiles(files)} />
    </div>
  );
}
```

The `onDone` prop is a callback function that will be called when the user selects a file. It will be passed an array of `FileInfo` objects if the `multiple` prop is set to `true`, or a single `FileInfo` object if `multiple` is `false`.

The `FileInfo` object has the following properties:

- `name` - the name of the file
- `type` - the MIME type of the file
- `size` - the size of the file in kilobytes
- `base64` - a Base64-encoded string of the file data
- `file` - the original `File` object

## Props

- `onDone` - (required) a callback function that will be called when the user selects a file
- `multiple` - (optional) a boolean value that determines whether the user can select multiple files (default `false`)

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