Salesforce Decode
Salesforcedecode
Back to questions
LWCAdvancedpaginationimperativeperformance

Implement client-side pagination with imperative Apex cursor API

Real World Scenario

Activity history LWC loads 50k Tasks on Account LDV parent. Offset pagination fails at page 200 with timeout.

Expected Answer

• Apex returns pageSize rows plus nextCursor lastId not offset integer • Client stores cursor chain; reset when parent recordId changes • Disable previous page if only forward cursor supported • Show loading skeleton during page fetch not blank table • Server enforces max pageSize cap regardless of client request • Empty state when no activities distinct from error state • Test pagination edge: last page, single page, cursor invalid

Follow-Up Questions & Answers

Click to expand — each follow-up includes a direct, interview-ready answer

Main difference: use case and scale. Apex returns pageSize rows plus nextCursor lastId not offset integer. Client stores cursor chain; reset when parent recordId changes. Pick based on your integration pattern and team capability. Offset pagination dies at LDV—cursor API is interview answer and production requirement. Optimize for scale and operational observability.

Architect Perspective

Offset pagination dies at LDV—cursor API is interview answer and production requirement.