Entity Lists
Entity lists in Replyke provide powerful feed and list management functionality using Redux state management. The useEntityList hook allows you to create, manage, and filter lists of entities with built-in pagination, caching, and real-time updates.
Quick Start
Core Concepts
List IDs
Each entity list requires a unique listId. This is a client-side identifier that allows multiple independent lists to coexist in your application with their own state, filters, and cached data.
Think of listId as creating separate “instances” of entity lists in your Redux store. Each list maintains:
- Its own entities array
- Independent filter states
- Separate loading states
- Individual pagination state
Common listId patterns:
- Static feeds:
"main-feed", "trending", "popular"
- User-specific:
"user-${userId}", "user-${userId}-favorites"
- Search/filters:
"search-${query}", "category-${categoryId}"
- Temporary lists:
"modal-feed", "drawer-content"
Important: The listId is purely for client-side state management and doesn’t affect which entities are fetched from the server. Use sourceId in your fetch configuration to control which entities are returned from Replyke.
Source IDs (Critical Concept)
Always use sourceId when creating entities. The sourceId logically separates different types of content within your project, preventing them from mixing inappropriately.
Why sourceId Matters
Imagine you’re building an image-sharing app but also have a product blog. Without sourceId:
- Your image feed could suddenly show blog articles
- Blog subscribers might see random user photos
- Content gets mixed unintentionally
With proper sourceId separation:
Fetching by sourceId
Best Practices for sourceId
✅ Always use sourceId, even initially:✅ Use descriptive names:
"user-posts" - User-generated content
"blog-articles" - Official blog posts
"product-reviews" - Product reviews
"help-docs" - Documentation content
"announcements" - Company announcements
Filters vs Configuration
Entity lists accept two types of parameters:
- Filters: User-controlled parameters like sorting, time frames, and content filters
- Configuration: System-level parameters like
sourceId and pagination limit
Hook Interface
Available Filters
Entity lists support comprehensive filtering options:
- sortBy:
"hot", "new", "top", "controversial"
- timeFrame:
"hour", "day", "week", "month", "year"
- userId: Filter by specific user
- followedOnly: Show only followed users’ content
- Content filters: Title, content, keywords, attachments, location, metadata
See the filters documentation for detailed examples of each filter type.
Advanced Features
External Data Integration
Use the infuseData callback to merge external data with entities:
Dynamic Filtering
Update filters by calling fetchEntities with new parameters:
Multiple Lists
Create multiple independent lists for different use cases:
Error Handling
The hook automatically handles errors and provides loading states:
- Entity lists use Redux for state management, providing automatic caching and persistence
- The
fetchEntities function includes debouncing for filter changes (800ms delay)
- Use
options.immediate: true to bypass debouncing when needed
- Each list maintains independent state based on its
listId