npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@capacitor/file-viewer

v2.0.1

Published

The FileViewer API provides mechanisms for opening files and previewing media. Not available on web.

Readme

@capacitor/file-viewer

The FileViewer API provides mechanisms for opening files and previewing media. Not available on web.

The media preview methods are currently only supported on iOS. It uses a built-in player.

Install

npm install @capacitor/file-viewer
npx cap sync

Example

import { FileViewer } from "@capacitor/file-viewer";

// can use a plugin like @capacitor/filesystem to get the full path to the file
const openDocument = async () => {
  await FileViewer.openDocumentFromLocalPath({
    path: "path/to/file.pdf"
  });
};

// ios-specific
const previewMedia = async () => {
  await FileViewer.previewMediaContentFromUrl({
    path: "https://url_hosting_media/file.mp4"
  });
}

API

For list of existing error codes, see Errors.

File Viewer API

Only available in Native Android and iOS; not available for Web / PWAs.

openDocumentFromLocalPath(...)

openDocumentFromLocalPath(options: OpenFromLocalPathOptions) => Promise<void>

Open a file stored in the local file system

| Param | Type | | ------------- | ----------------------------------------------------------------------------- | | options | OpenFromLocalPathOptions |

Since: 1.0.0


openDocumentFromResources(...)

openDocumentFromResources(options: OpenFromResourcesOptions) => Promise<void>

Open an app resource file

| Param | Type | | ------------- | ----------------------------------------------------------------------------- | | options | OpenFromResourcesOptions |

Since: 1.0.0


openDocumentFromUrl(...)

openDocumentFromUrl(options: OpenFromUrlOptions) => Promise<void>

Open a file from a remote url

| Param | Type | | ------------- | ----------------------------------------------------------------- | | options | OpenFromUrlOptions |

Since: 1.0.0


previewMediaContentFromLocalPath(...)

previewMediaContentFromLocalPath(options: PreviewMediaFromLocalPathOptions) => Promise<void>

Preview a media file (namely, video) stored in the local file system. Only implemented in iOS. Android defaults to openDocumentFromLocalPath.

| Param | Type | | ------------- | ----------------------------------------------------------------------------- | | options | OpenFromLocalPathOptions |

Since: 1.0.0


previewMediaContentFromResources(...)

previewMediaContentFromResources(options: PreviewMediaFromResourcesOptions) => Promise<void>

Preview a media file (namely, video) from the app's resources. Only implemented in iOS. Android defaults to openDocumentFromResources.

| Param | Type | | ------------- | ----------------------------------------------------------------------------- | | options | OpenFromResourcesOptions |

Since: 1.0.0


previewMediaContentFromUrl(...)

previewMediaContentFromUrl(options: PreviewMediaFromUrlOptions) => Promise<void>

Preview a media file (namely, video) from a remote url. Only implemented in iOS. Android defaults to openDocumentFromUrl.

| Param | Type | | ------------- | ----------------------------------------------------------------- | | options | OpenFromUrlOptions |

Since: 1.0.0


Interfaces

OpenFromLocalPathOptions

| Prop | Type | Description | Since | | ---------- | ------------------- | ------------------------------------------ | ----- | | path | string | The full absolute path to the file to open | 1.0.0 |

OpenFromResourcesOptions

| Prop | Type | Description | Since | | ---------- | ------------------- | ---------------------------------------------- | ----- | | path | string | The relative path to the resource file to open | 1.0.0 |

OpenFromUrlOptions

| Prop | Type | Description | Since | | --------- | ------------------- | ------------------------------------------- | ----- | | url | string | The remote url pointing to the file to open | 1.0.0 |

Type Aliases

PreviewMediaFromLocalPathOptions

OpenFromLocalPathOptions

PreviewMediaFromResourcesOptions

OpenFromResourcesOptions

PreviewMediaFromUrlOptions

OpenFromUrlOptions

Errors

The plugin returns the following errors with specific codes on native Android and iOS:

| Error code | Platform(s) | Message | |-------------------|------------------|------------------------------| | OS-PLUG-FLVW-0004 | Android, iOS | The file you are trying to open does not exist. | | OS-PLUG-FLVW-0005 | Android, iOS | The URL you are trying to open is malformed. | | OS-PLUG-FLVW-0006 | Android, iOS | Path of the file to open is either null or empty. | | OS-PLUG-FLVW-0007 | Android, iOS | URL to open is either null or empty. | | OS-PLUG-FLVW-0008 | Android, iOS | Could not open the file. | | OS-PLUG-FLVW-0009 | Android, iOS | Invalid parameters. | | OS-PLUG-FLVW-0010 | Android | There is no app to open this file. | | OS-PLUG-FLVW-0011 | iOS | Cordova / Capacitor bridge isn’t initialized. | | OS-PLUG-FLVW-0012 | iOS | The download failed. | | OS-PLUG-FLVW-0013 | iOS | The file has no extension. |