flâneur — a map of the web's best reading

Learn Next.js: Adding Search and Pagination | Next.js

nextjs.org · 3,305 words · saved by 1 readers

In the previous chapter, you improved your dashboard's initial loading performance with streaming. Now let's move on to the /invoices page, and learn how to add search and pagination! In this chapter... Here are the topics we’ll cover Learn how to use the Next.js APIs: searchParams, usePathname, and useRouter. Implement search and pagination using URL search params. Inside your /dashboard/invoices/page.tsx file, paste the following code: Spend some time familiarizing yourself with page, and the components you'll be working with: Your search functionality will span the client and the server. When a user searches for an invoice on the client, the URL params will be updated, data will be fetched on the server, and the table will re-render on the server with the new data. As mentioned above, you'll be using URL search params to manage the search state. This pattern may be new if you're used to doing it with client-side state. There are a couple of benefits of implementing search with URL p

10 Chapter 10 Adding Search and Pagination In the previous chapter, you improved your dashboard's initial loading performance with streaming. Now let's move on to the /invoices page, and learn how to add search and pagination. In this chapter... Here are the topics we'll cover Learn how to use the Next.js APIs: useSearchParams , usePathname , and useRouter . Implement search and pagination using URL search params. Starting code Inside your /dashboard/invoices/page.tsx file, paste the following code: /app/dashboard/invoices/page.tsx import Pagination from '@/app/ui/invoices/pagination' ; import

Explore this link on the map →

related reading