Store Setup
Folder Structure
src/
app/
store.ts # Store configuration
hooks.ts # Typed hooks (useAppDispatch/useAppSelector)
shared/
types/ # DTOs (API), Domain models, mappers
utils/ # Shared utilities
services/
client.ts # RTK Query base client
baseQuery.ts # Base query with auth/chainId/retry
features/
user/
user.client.ts # RTK Query endpoints
user.slice.ts # UI state slice
user.selectors.ts # Memoized selectors
__tests__/ # Tests
land/
land.client.ts
land.slice.ts
land.selectors.ts
credits/
credits.client.ts
credits.slice.ts
credits.selectors.tsFolder Organization Principles
Store Configuration
Basic Store Setup
Configuration Options
Serializable Check
Dev Tools
Typed Hooks
Hook Setup
Usage in Components
Benefits of Typed Hooks
Provider Setup
Next.js App Router
Next.js Pages Router
React (Vite/CRA)
Environment Configuration
Type Definitions
Multiple Store Instances
Best Practices
1. Single Store
2. Lazy Loading Reducers
3. Hot Module Replacement
4. State Persistence
Next Steps
Last updated