Prepared Docs

Prepared Docs

⌘K

    Loading navigation…

User

  1. Working With Data
  2. Local Storage

Local Storage

Type-safe localStorage with versioning and error handling.

Quick Reference

Best practices:

  • Version keys (userConfig:v1) for schema evolution
  • Store minimal data (only what UI needs)
  • Always wrap in try-catch (throws in incognito/quota exceeded)
  • Never store tokens, PII, or sensitive data

Basic Pattern

With Prepared Patterns

Schema Versioning

When schema changes, migrate old data:

Type-Safe Wrapper

React Hook

Minimize Stored Data

Only store what the UI needs—not full server responses:

Common Pitfalls

Never store sensitive data:

Always handle errors:

Use versioned keys:

Related Documentation

  • State Management - When to use localStorage vs Zustand
  • Writing Hooks - Custom hooks patterns

Reference Files

For more detailed technical guidance, see these reference files:

  • client-localstorage-schema.md

Previous

Working with data / GraphQL Development Workflow

Next

Testing strategy / Testing Principles

On this page

Quick Reference
Basic Pattern
With Prepared Patterns
Schema Versioning
Type-Safe Wrapper
React Hook
Minimize Stored Data
Common Pitfalls
Related Documentation
Reference Files