No slash command · from react-native-plugin
Guides state management and storage choices in React Native. Covers Zustand, Jotai, Redux Toolkit, TanStack Query, Context for state; AsyncStorage, MMKV, SecureStore, Keychain for storage. Includes hydration patterns, splash screen handling, and secrets discipline.
Ships in react-native-plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
State management is largely identical to web React. Storage is the genuinely RN-specific concern.
| Need | Tool |
|---|---|
| Local component state | useState, useReducer |
| Shared between siblings | Lift to common parent OR Context |
| App-wide UI state (theme, modals, sidebars) | Context, Zustand, or Jotai |
| Server data with caching | TanStack Query, SWR |
| Complex domain state | Redux Toolkit (or Zustand for simpler cases) |
| Form state | react-hook-form |
Same decision tree as web — see react-plugin:react-state-management skill for deep dive on each tool. RN-specific notes below.
Context survives Fast Refresh ONLY if values are not held in module-level closure. Store provider state in useState / useReducer inside the provider component, not in a top-level let.
// ✅ Survives Fast Refresh
export function ThemeProvider({ children }: { children: React.ReactNode }) {
const [theme, setTheme] = useState<Theme>('light');
return <ThemeContext.Provider value={{ theme, setTheme }}>{children}</ThemeContext.Provider>;
}
// ❌ Lost on Fast Refresh
let theme: Theme = 'light';
export const ThemeContext = createContext({ theme, setTheme: (t: Theme) => { theme = t; } });
import { create } from 'zustand';
import { persist, createJSONStorage } from 'zustand/middleware';
import AsyncStorage from '@react-native-async-storage/async-storage';
export const useUserStore = create(
persist(
(set) => ({ user: null, setUser: (user: User | null) => set({ user }) }),
{
name: 'user-storage',
storage: createJSONStorage(() => AsyncStorage),
}
)
);
For sensitive data, swap AsyncStorage for SecureStore wrapper:
import * as SecureStore from 'expo-secure-store';
const secureStorage = {
getItem: (key: string) => SecureStore.getItemAsync(key),
setItem: (key: string, value: string) => SecureStore.setItemAsync(key, value),
removeItem: (key: string) => SecureStore.deleteItemAsync(key),
};
storage: createJSONStorage(() => secureStorage),
Note: SecureStore values are limited to ~2KB on iOS. For larger sensitive data, encrypt with expo-crypto and store ciphertext in MMKV.
Works identically to web, but consider:
@react-native-community/netinfo to gate queries when offline.@tanstack/react-query-persist-client + AsyncStorage/MMKV for offline-first apps.refetchOnWindowFocus (web); for RN, manually trigger via AppState listener.import { AppState } from 'react-native';
import { focusManager } from '@tanstack/react-query';
useEffect(() => {
const sub = AppState.addEventListener('change', (state) => {
focusManager.setFocused(state === 'active');
});
return () => sub.remove();
}, []);
The RN-specific decision. Each has a place.
@react-native-async-storage/async-storage)Async key-value, plaintext on disk. Most common, but NOT secure.
import AsyncStorage from '@react-native-async-storage/async-storage';
await AsyncStorage.setItem('@theme', 'dark');
const theme = await AsyncStorage.getItem('@theme'); // string | null
await AsyncStorage.removeItem('@theme');
await AsyncStorage.multiGet(['@a', '@b']); // [[key, value], ...]
await AsyncStorage.multiSet([['@a', '1'], ['@b', '2']]);
Use for:
NEVER:
react-native-mmkv)Synchronous, fast (~30x faster than AsyncStorage), encrypted optional. Modern preferred for non-secrets.
import { MMKV } from 'react-native-mmkv';
const storage = new MMKV();
storage.set('theme', 'dark'); // sync, no await needed
const theme = storage.getString('theme'); // 'dark' or undefined
storage.delete('theme');
storage.contains('theme'); // boolean
storage.getAllKeys(); // string[]
Optional encryption:
const storage = new MMKV({
id: 'user-storage',
encryptionKey: 'a-secret-key-from-secure-store',
});
Use for:
Caveat: requires JSI / native build — works in dev-client, EAS Build, bare. NOT in Expo Go (managed without dev client).
expo-secure-store)Keychain (iOS) / EncryptedSharedPreferences (Android). For sensitive data.
import * as SecureStore from 'expo-secure-store';
await SecureStore.setItemAsync('refresh-token', token);
const token = await SecureStore.getItemAsync('refresh-token');
await SecureStore.deleteItemAsync('refresh-token');
Use for:
Limits:
react-native-keychain)Bare alternative to SecureStore. Same purpose, more configuration options (access groups, biometric prompts).
import * as Keychain from 'react-native-keychain';
await Keychain.setGenericPassword('username', 'password');
const credentials = await Keychain.getGenericPassword();
if (credentials) console.log(credentials.username, credentials.password);
await Keychain.resetGenericPassword();
For finer control:
await Keychain.setInternetCredentials('api.example.com', 'username', 'token', {
accessControl: Keychain.ACCESS_CONTROL.BIOMETRY_CURRENT_SET,
accessible: Keychain.ACCESSIBLE.WHEN_UNLOCKED_THIS_DEVICE_ONLY,
});
Use in bare projects or when SecureStore's API is too limited.
| Data | Storage |
|---|---|
| Auth tokens (JWT, refresh) | SecureStore / Keychain |
| OAuth tokens | SecureStore / Keychain |
| User credentials (rare — prefer not storing) | Keychain with biometric |
| Theme preference | MMKV or AsyncStorage |
| Locale | MMKV or AsyncStorage |
| Onboarding seen flag | MMKV or AsyncStorage |
| Cached server data (offline-first) | TanStack Query persist + MMKV/AsyncStorage |
| Large blobs (images, files) | expo-file-system (managed) or react-native-fs (bare) |
| Database-like queries | expo-sqlite, WatermelonDB, op-sqlite |
Read storage, populate state, hide splash screen — in that order.
// app/_layout.tsx (Expo Router) or App.tsx
import * as SplashScreen from 'expo-splash-screen';
import { useEffect, useState } from 'react';
import { useUserStore } from '@/stores/userStore';
SplashScreen.preventAutoHideAsync();
export default function RootLayout() {
const [hydrated, setHydrated] = useState(false);
const restoreUser = useUserStore((s) => s.restoreUser);
useEffect(() => {
(async () => {
await restoreUser();
setHydrated(true);
})();
}, [restoreUser]);
useEffect(() => {
if (hydrated) SplashScreen.hideAsync();
}, [hydrated]);
if (!hydrated) return null;
return <App />;
}
Zustand persist middleware exposes hasHydrated:
const { isHydrated } = useUserStore.persist;
if (!isHydrated()) return <SplashScreen />;
Or subscribe via useStore selector:
const hasHydrated = useUserStore((s) => s._hasHydrated);
No Expo splash. Use react-native-bootsplash or implement custom splash UI.
console.log / analytics call.keychainService and access group flags.multiGet / multiSet.await AsyncStorage operations — silent races.console.log for "debugging".Constants.expoConfig.extra — that's read-only build-time config, not runtime state.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub aratkruglik/claude-sdlc --plugin react-native-plugin5 skills in this plugin
/rn-conventionsReact Native project structure, Expo vs bare workflow detection, app.json/app.config.js patterns, asset handling, fonts, styling approaches, hot-reload-friendly idioms.
Use this skill to:
- Detect Expo (managed/dev-client/EAS/ejected) vs bare RN workflow.
- Pick correct project layout for each workflow.
- Configure app.json / app.config.js with bundle ID, splash, icons, deep link schemes.
- Handle assets, fonts, images correctly.
- Pick a styling approach (StyleSheet / NativeWind / restyle / styled-components).
Do NOT use this skill for:
- Platform-specific branching (see rn-platform-specific).
- Navigation (see rn-navigation).
- Storage (see rn-state-and-storage).
- Testing (see rn-testing).
/rn-navigationNavigation in React Native — both React Navigation v7 (classical, modular) and Expo Router (file-based, Expo 49+). Stack, tab, drawer navigators, deep linking, typed navigation, modal presentation, authentication flow patterns.
Use this skill to:
- Pick navigation lib based on what's installed (@react-navigation/* vs expo-router).
- Configure typed routes with ParamList types or Expo Router's generated types.
- Set up deep linking (URL schemes, Universal Links, App Links).
- Build authentication flow with conditional navigators.
- Use modal presentation correctly.
Do NOT use this skill for:
- Project structure (see rn-conventions).
- Platform-specific differences (see rn-platform-specific).
- State / storage (see rn-state-and-storage).
- Testing navigation (see rn-testing).
/rn-platform-specificiOS / Android platform-specific code in React Native: Platform.OS, Platform.select, .ios.tsx / .android.tsx file extensions, native modules, permissions, safe area handling, status bar.
Use this skill to:
- Branch code at runtime via Platform.OS / Platform.select.
- Use file extensions for whole-component swaps.
- Link and use native modules (Expo SDK or autolinked bare).
- Handle permissions across platforms.
- Configure status bar and safe area correctly.
Do NOT use this skill for:
- General project structure (see rn-conventions).
- Navigation (see rn-navigation).
- Storage (see rn-state-and-storage).
- Testing (see rn-testing).
/rn-testingTesting React Native: Jest with jest-expo / react-native preset, React Testing Library Native, native module mocking, hook testing. Optional sections for Detox (native automation) and Maestro (declarative YAML e2e).
Use this skill to:
- Configure Jest preset based on workflow.
- Write component tests with @testing-library/react-native.
- Mock native modules (react-native-reanimated, expo-*, react-native-mmkv).
- Test custom hooks via renderHook.
- Set up Detox or Maestro for e2e (optional, requires native toolchain).
Do NOT use this skill for:
- General RN conventions (see rn-conventions).
- Web-React testing (see react-plugin:react-testing — different jsdom setup).
- Plain Node testing patterns (see nodejs-plugin equivalents).
Other plugins' skills for the same job