# react-native-file-opener3

> A React Native module that allows you to open a file (mp3, mp4, pdf, word, excel, dwg etc.) on your device with its default application

Latest version **0.3.4** (published 2021-11-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-native-file-opener3
pnpm add react-native-file-opener3
yarn add react-native-file-opener3
bun add react-native-file-opener3
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.4 |
| Published | 2021-11-16 |
| First published | 2019-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | reylen |
| Maintainers | reylen |
| Keywords | react-native, react-native-file-opener, react, native, file, opener, mp3, mp4, pdf, office, dwg, word, cad, excel |

## Links

- npm: https://www.npmjs.com/package/react-native-file-opener3
- Repository: https://github.com/reylen/react-native-file-opener3
- Homepage: https://github.com/reylen/react-native-file-opener3#readme
- Issues: https://github.com/reylen/react-native-file-opener3/issues
- npm.io page: https://npm.io/package/react-native-file-opener3

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 0.3.4 (latest) — 2021-11-16
- 0.3.3 — 2021-08-18
- 0.3.2 — 2020-11-26
- 0.3.1 — 2019-10-15
- 0.3.0 — 2019-09-26

## README

react-native-file-opener
-
A React Native module that allows you to open a file (mp3, mp4, pdf, word, excel, dwg etc.) on your device with its default application

New add podspec, pod manager. No need to react-native link this file.

iOS | Android
------- | ----
<img title="iOS" src="https://github.com/huangzuizui/react-native-file-opener/blob/master/assets/ios_screen.gif"> | <img title="Android" src="https://raw.githubusercontent.com/huangzuizui/react-native-file-opener/master/assets/android_screen.gif">

# Install
##iOS
1. `npm install react-native-file-opener3 --save`

No link need! podspec added yet.

2. Compile and have fun

##Android
* `npm install react-native-file-opener3 --save`


##Usage
1. In your React Native javascript code, bring in the native module
```javascript
const FileOpener = require('react-native-file-opener3');
OR
import FileOpener from 'react-native-file-opener3';
```
2. Basic usage
```javascript
const FilePath = ...; // path of the file
const FileMimeType = ...; // mime type of the file
FileOpener.open(
    FilePath,
    FileMimeType
).then((msg) => {
    console.log('success!!')
},() => {
    console.log('error!!')
});
```
##Usage with react-native-fs
* You can get filepath by using [react-native-fs](https://github.com/johanneslumpe/react-native-fs)

```javascript
const RNFS = require('react-native-fs');
const FileOpener = require('react-native-file-opener3');

const SavePath = Platform.OS === 'ios' ? RNFS.DocumentDirectoryPath : RNFS.ExternalDirectoryPath;
const sampleDocFilePath = SavePath + '/sample.doc';

...

  function openSampleDoc() {
        FileOpener.open(
            sampleDocFilePath,
            'application/msword'
        ).then(() => {
            console.log('success!!');
        },(e) => {
            console.log('error!!');
        });

    }
    
...
```
##Demo project
[https://github.com/huangzuizui/react-native-file-opener-demo](https://github.com/huangzuizui/react-native-file-opener-demo)

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