Pagination container
The Pagination container handles paging for search results. It shows next, previous, and page number controls and keeps the page in sync with the results.
Import
Section titled “Import”import Pagination from '@dropins/storefront-product-discovery/containers/Pagination.js';Configurations
Section titled “Configurations”The Pagination container provides the following configuration options:
Basic Usage
Section titled “Basic Usage”await provider.render(Pagination)($container);Features
Section titled “Features”Automatic Page Management
Section titled “Automatic Page Management”- Page State: Automatically tracks current page and total pages from search results
- Page Info: Extracts pagination data from
pageInfo.currentPageandpageInfo.totalPages - Conditional Rendering: Only renders when pagination data is available
- Search Integration: Page changes trigger new search calls with updated page parameters
Navigation Controls
Section titled “Navigation Controls”- Page Numbers: Direct navigation to specific pages
- Current Page Display: Shows current page position
- Total Pages: Displays total number of available pages
- Responsive Design: Adapts to different screen sizes
Scope Support
Section titled “Scope Support”The Pagination container supports isolated instances through scope configuration:
// Global scope (default) Listens to all search eventsawait provider.render(Pagination)($container);
// Only listens to events with scope: 'popover'await provider.render(Pagination, { scope: 'popover' })($container);Real-time Updates
Section titled “Real-time Updates”The container automatically updates when search events are received:
- Search Results: Updates pagination based on
pageInfofrom results - Page Changes: Automatically triggers new searches with updated page
Integration Examples
Section titled “Integration Examples”Basic PLP Setup
Section titled “Basic PLP Setup”await provider.render(Pagination, { onPageChange: (page) => { // scroll to the top of the page after changing pages window.scrollTo({ top: 0, behavior: 'smooth' }); }})($paginationContainer);Best Practices
Section titled “Best Practices”- Scope Management: Use unique scope identifiers for multiple instances
- Page Callbacks: Use
onPageChangefor custom page handling - Real-time Updates: Let the container handle updates automatically
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”- Container Not Updating: Check scope configuration and event handling
- Page Not Changing: Verify search API is being called with correct page
- Container Not Rendering: Ensure search results include
pageInfodata - Styling Conflicts: Use specific CSS classes to avoid conflicts
Pagination Behavior
Section titled “Pagination Behavior”- Conditional Rendering: Container only renders when
currentPageandtotalPagesare available - Search Integration: Page changes automatically trigger new search calls
- State Management: Page state is maintained through search variables