relay-pagination

Implement cursor-based pagination in Relay GraphQL applications with usePaginationFragment.

187|20|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/TheBushidoCollective/han --skill relay-pagination
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: relay-pagination
Source: https://github.com/TheBushidoCollective/han/tree/main/jutsu/jutsu-relay/skills/relay-pagination
Command: npx skills add https://github.com/TheBushidoCollective/han --skill relay-pagination

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Efficiently paginate large datasets in Relay using cursor connections, supporting infinite scroll, load more, and bidirectional navigation.

Core Features & Use Cases

  • Basic Pagination: Edges, node data, and pageInfo for next/previous pages
  • Infinite Scroll: Intersection-based loading for seamless UX
  • Bidirectional Pagination: Jump forward and backward with consistent state
  • Production Patterns: Real-world patterns for scalable data loading

Quick Start

Integrate usePaginationFragment, render edges, and load more data on user interaction.

Frequently Asked Questions about relay-pagination

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement cursor-based pagination in Relay GraphQL applications?

Cursor-based pagination in Relay uses usePaginationFragment to manage edges with cursors and pageInfo metadata. Implement it by setting up @refetchable fragments, rendering edges with node data, and calling loadNext or loadPrevious hooks to fetch additional pages without re-querying the entire dataset.

What's the difference between cursor-based and offset-based pagination for GraphQL?

Cursor-based pagination uses opaque cursors to track position within a dataset, making it more efficient and stable when data changes between requests. Relay's cursor approach handles first/after/last/before arguments and supports bidirectional navigation without the performance and consistency issues offset-based pagination introduces.

Can I use Relay pagination with infinite scroll in React components?

Yes, Relay pagination supports infinite scroll through usePaginationFragment and intersection-based loading triggers. Combine loadNext with an Intersection Observer to automatically fetch pages as users scroll, creating seamless loading without page boundaries.

How do I handle bidirectional navigation with Relay cursor connections?

Relay cursor connections support bidirectional pagination through loadNext and loadPrevious hooks, which manage forward and backward traversal. Use @connection directives to maintain cache consistency and pass first/after or last/before arguments to navigate both directions while preserving UI state.

What GraphQL fields are required for Relay cursor pagination to work?

Relay cursor pagination requires edges containing cursor and node, plus pageInfo with hasNextPage, hasPreviousPage, startCursor, and endCursor fields. These fields enable the usePaginationFragment hook to determine pagination state and construct queries with first/after/last/before arguments.

Do I need a load-more pattern or can I use only infinite scroll with Relay?

Relay supports both patterns. Use infinite scroll with Intersection Observer for seamless loading, or implement explicit load-more buttons by calling loadNext on user action. Choose based on UX preference and dataset size; both patterns use the same usePaginationFragment and @connection infrastructure.