Cheat Sheets

React Native AsyncStorage & APIs Cheat Sheet: Persist Data, Fetch & Permissions

By ArpaNeuro Team September 16, 2026
React Native AsyncStorage cheat sheet

AsyncStorage is an unencrypted, asynchronous key-value store for small JSON. Use it for preferences and caches, not secrets (use SecureStore or Keychain). Network is still fetch. Camera, location, and notifications need runtime permissions that differ per platform.

This React Native cheat sheet is written for people searching for a fast, accurate reference: students, junior developers, and teams shipping production software. Pin it, copy the snippets, and come back when syntax slips.

Quick reference

  • AsyncStorage: await AsyncStorage.setItem(key, jsonString) — always strings.
  • JSON: Stringify/parse with try/catch. Missing keys return null.
  • Secure: Tokens belong in expo-secure-store or a native keychain wrapper, not AsyncStorage.
  • fetch: Same Fetch API. Handle ok, timeouts, and abort on unmount.
  • Files: FormData for uploads. Libraries like expo-file-system for local files.
  • Permissions: Ask in context. iOS Info.plist strings must exist or the app crashes on prompt.
  • Offline: Queue writes, show cached JSON, and tell the user when you are stale.
  • Multi: multiGet / multiSet to batch. Do not hammer storage in a render loop.

Copy-paste examples

Typed JSON cache helper

AsyncStorage is async — never call it during render. Gate secrets away from this helper.

import AsyncStorage from '@react-native-async-storage/async-storage';

export async function saveCache(key, value) {
  await AsyncStorage.setItem(key, JSON.stringify(value));
}
export async function readCache(key, fallback = null) {
  const raw = await AsyncStorage.getItem(key);
  if (!raw) return fallback;
  try {
    return JSON.parse(raw);
  } catch {
    return fallback;
  }
}

Common mistakes

  • Storing JWTs in AsyncStorage on a JS-bundle that might be XSS-adjacent (WebViews) or on rooted devices without caring.
  • Using web localStorage APIs — they are not on native.
  • Blocking the UI with a long JSON parse on the JS thread during launch.
  • Fetching without handling airplane mode or token refresh.

FAQ

  1. Is AsyncStorage the same as localStorage? Same idea (string map), different API (async, no window). Do not copy-paste web storage helpers.
  1. When do I need a real database? When you query, index, or store lots of rows — SQLite/Watermelon/Realm. AsyncStorage is not SQL.
  1. How do I attach a photo to POST? FormData.append("photo", { uri, name, type }) with the shape your RN version expects, then fetch POST.

Related React Native cheat sheets

Build with this stack

When a cheat sheet is not enough — you need a production app, a student FYP, or a custom dashboard — ArpaNeuro builds mobile app development and also sells ready-made source code. Request a quote and tell us the stack.

Browse software development services or the source code marketplace if you want a working codebase instead of starting from a blank file.

← All Articles Get a Quote →