Concepts
Pagination
page / offset / cursor strategies, query param names, and response shape
GET list endpoints (/api/user) are paginated according to
mock.config.js's pagination block. Every transport (react, next)
shares the same implementation, so behavior is identical regardless of how
you're serving the data.
Strategies
Set via pagination.strategy:
'page'(default):?page=2&limit=20. Responsemeta:{ strategy: 'page', total, page, limit, pageCount }.'offset':?offset=40&limit=20. Responsemeta:{ strategy: 'offset', total, offset, limit }.'cursor':?cursor=<opaque>&limit=20. Responsemeta:{ strategy: 'cursor', total, limit, nextCursor }.nextCursorisnullonce there's nothing left.false: pagination disabled entirely;GETreturns every record.
Query parameter names
Customizable per-project via pagination.params, the defaults:
params: { page: 'page', limit: 'limit', offset: 'offset', cursor: 'cursor' }Rename limit to perPage, for instance, if that's your existing API's
convention:
pagination: { params: { limit: 'perPage' } }Bounds and fallbacks
- An invalid or non-positive
limitin the query string falls back topagination.defaultLimit. It never produces a500or an empty result because of a malformed query param. limitis always clamped topagination.maxLimit, even if the query string asks for more.
Response envelope
pagination.envelope controls the response body shape:
true(default):{ data: [...], meta: {...} }.false: a bare array as the body, with pagination info moved to response headers instead:X-Total-Count,X-Limit, and whichever ofX-Page/X-Offset/X-Next-Cursorapplies to the active strategy.
Pick false if your app's HTTP client (or an existing real API you're
mocking the shape of) expects a raw array rather than an envelope object.