Paginación por cursor con Redux Toolkit

Paginación por cursor con Redux Toolkit: maneja items, nextCursor, previousCursor, sort, loading y errores; carga inicial, navegación entre páginas y reinicio al cambiar el orden para APIs sin offsets. Soluciones de Q2BSTUDIO.

10 sept 2025 • 3 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

La paginación por cursor es una técnica eficiente para navegar resultados grandes sin perder rendimiento. En este enfoque se manejan cuatro elementos clave: items que son los resultados de la página actual, nextCursor que indica dónde pedir la siguiente página, previousCursor para retroceder y sort para aplicar orden. Además conviene manejar estados de red como loading y error para ofrecer una experiencia correcta al usuario.

En Redux Toolkit se implementa típicamente creando un thunk asincrónico para pedir a la API la página según el cursor y el orden, y un slice que almacene items, nextCursor, previousCursor, sort, loading y error. El thunk realiza la petición a una ruta tipo api/items?cursor=...&sort=... y al resolver rellena items y los cursores. En el slice se definen reducers para cambiar el orden y extraReducers para gestionar pending, fulfilled y rejected y así activar loading y capturar errores.

La configuración del store es directa con configureStore incluyendo el reducer de paginación. En la aplicación se envuelve todo con Provider y se usa useSelector para leer items, cursores y estados, y useDispatch para lanzar fetchPage y changeSorting. En el componente principal se hace una carga inicial con useEffect solicitando la primera página con cursor null y el sort actual. Los botones Siguiente y Anterior lanzan fetchPage con nextCursor o previousCursor según convenga. Al cambiar el orden se actualiza el estado sort y se vuelve a solicitar la página inicial para reiniciar la navegación con la nueva ordenación.

Flujo resumido: el usuario abre la página, useEffect dispara fetchPage con cursor null, Redux pasa por pending y luego fulfilled llenando items y cursores. Al pulsar Siguiente se solicita fetchPage con nextCursor y se actualizan items y cursores. Al cambiar orden se guarda el nuevo sort y se vuelve a pedir la primera página.

Este patrón es ideal para APIs que devuelven cursores en lugar de offsets porque evita costes crecientes al paginar y mantiene consistencia entre páginas. Para implementar correctamente hay que controlar el estado loading, mostrar errores y deshabilitar botones cuando no hay cursores disponibles.

En Q2BSTUDIO ofrecemos experiencia en desarrollar soluciones escalables que incorporan este tipo de paginación dentro de aplicaciones a medida y software a medida. Si necesitas una interfaz que maneje grandes volúmenes de datos con rendimiento y control de estados podemos ayudarte a integrarlo junto a servicios cloud como AWS y Azure o soluciones de inteligencia artificial a medida. Conocemos buenas prácticas para combinar paginación por cursor con servicios de aplicaciones a medida y pipelines de datos.

Además ofrecemos servicios de inteligencia artificial para empresas, agentes IA y consultoría de IA aplicada que combinan búsquedas paginadas eficientes con modelos que mejoran relevancia y experiencia de usuario. Con Q2BSTUDIO también puedes complementar tu proyecto con ciberseguridad, pentesting, servicios cloud aws y azure y herramientas de inteligencia de negocio como Power BI para obtener informes y métricas accionables. Conecta tu proyecto con nuestros servicios de inteligencia artificial para potenciar búsquedas, recomendaciones y automatización.

Palabras clave integradas: aplicaciones a medida, software a medida, inteligencia artificial, ciberseguridad, servicios cloud aws y azure, servicios inteligencia de negocio, ia para empresas, agentes IA y power bi. Si quieres un prototipo o desarrollo completo con paginación por cursor y arquitectura profesional, contacta con Q2BSTUDIO y diseñaremos la solución a medida que necesitas.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat