React Native Cloud Storage

Introduction

iCloud and Google Drive for React Native.

React Native Cloud Storage allows you to use iCloud (iOS only) and Google Drive as file storage in your React Native app. The API of its core functionality follows the conventions of the Node.js module fs. React hooks and other utilities make working with cloud files even easier.

Features

  • fs-like APIreadFile, writeFile, appendFile, readdir, mkdir, stat, unlink, and more, modeled on Node's fs so there's almost nothing new to learn.
  • Two providers, one APIiCloud (via a native CloudKit module) and Google Drive (via the REST API). Use the platform default or switch between them at runtime.
  • React hooksuseCloudFile and useIsCloudAvailable keep your components in sync with cloud state.
  • Scopes — read and write in a hidden, app-private container (AppData) or the user-visible iCloud Drive / Google Drive Documents folder.
  • Expo config plugin — configures the native iCloud capability automatically, with no manual Xcode steps.
  • Built for the New Architecture — ships as a Turbo Module and is fully typed with TypeScript.

Quick example

import { CloudStorage, CloudStorageScope } from 'react-native-cloud-storage';

// Write a JSON file to the app-private scope (iCloud on iOS, Google Drive elsewhere).
await CloudStorage.writeFile('/state.json', JSON.stringify({ level: 7 }), CloudStorageScope.AppData);

// Read it back later.
if (await CloudStorage.exists('/state.json', CloudStorageScope.AppData)) {
  const json = await CloudStorage.readFile('/state.json', CloudStorageScope.AppData);
  const { level } = JSON.parse(json);
}

Prefer hooks? useCloudFile wraps this read/write cycle into a single reactive value.

Provider & platform support

ProvideriOSAndroidNotes
iCloudBacked by a native CloudKit module; available out of the box.
Google DriveBacked by the Drive REST API; you provide an access token.

By default, the library picks the right provider for each platform: iCloud on iOS, Google Drive everywhere else. You can override this or even use both providers at once.

Get started

On this page