TypeScript Types
Redux Remember exports the following TypeScript types for better type safety in your application.
Driver
Section titled “Driver”Storage driver interface for implementing custom storage solutions.
interface Driver { setItem(key: string, value: any): void | Promise<void>; getItem(key: string): any | Promise<any>;}See: Custom Storage Driver for complete implementation examples.
Options
Section titled “Options”Configuration options for rememberEnhancer.
interface Options { prefix?: string; serialize?: (state: any, key: string) => string; unserialize?: (state: string, key: string) => any; migrate?: (state: any) => any; persistThrottle?: number; persistDebounce?: number; persistWholeStore?: boolean; errorHandler?: (error: PersistError | RehydrateError | MigrateError) => void; initActionType?: string;}The errorHandler receives PersistError, RehydrateError, or MigrateError instances.
See: rememberEnhancer for detailed descriptions of each option.
Tip: It is highly recommended that you use use Redux Remigrate for type-safe migrations with auto-generated version types and CLI tooling.
Error Types
Section titled “Error Types”PersistError
Section titled “PersistError”class PersistError extends Error { // Thrown when persistence fails}Thrown when: State cannot be saved to storage (e.g., quota exceeded, storage unavailable).
RehydrateError
Section titled “RehydrateError”class RehydrateError extends Error { // Thrown when rehydration fails}Thrown when: State cannot be loaded from storage (e.g., corrupted data, parsing errors).
MigrateError
Section titled “MigrateError”class MigrateError extends Error { // Thrown when migration fails}Thrown when: The migrate function throws an error during state migration. When this occurs, the default store state (from reducer initial values) is used to prevent the app from crashing.
Note: Migration only runs if rehydration was successful. If rehydration fails, migration is skipped entirely.
See: Error Handling Guide for complete examples of handling these errors.
See Also
Section titled “See Also”- rememberEnhancer - API reference for using these types
- Migrations with Redux Remigrate - Use Redux Remigrate for migrations with auto-generated types and CLI tooling