getDefaultStore function returns the default global store instance. This is the store used when atoms are used without a Provider.
Signature
Type Definitions
Parameters
No parameters.Returns
The default global store instance. If it doesn’t exist yet, it will be created on first access.
Examples
Basic Usage
Outside React
Subscribe to Changes
Sync with External State
Debug Utility
Integration with DevTools
Server-Side Check
Multiple Instance Warning
Imperative Updates
Without Provider
Notes
- The default store is created lazily on first access
- The same instance is returned on every call (singleton pattern)
- In development mode, Jotai warns if multiple Jotai instances are detected (e.g., from duplicate packages)
- The default store is stored globally at
globalThis.__JOTAI_DEFAULT_STORE__in development - When using a Provider without a custom store, hooks still use the Provider’s store, not the default store
- Useful for imperative updates outside of React components
- Not recommended for SSR - use Provider with a custom store per request instead
- The default store persists for the lifetime of the application
Related APIs
- createStore - Create a custom store instance
- Provider - Provide a custom store to React components
- atom - Create atoms
- useAtom - Use atoms in React components