Loading video...

Video Failed to Load

Go Home

How should you search, filter, and paginate data with Next.js? This demo has 50,000 books in a Postgres database. • Page Load: When the page loads, we see the React Suspense fallback. This loading skeleton is displayed until the first page of books is retrieved from the database. •...

236,802 views • 2 years ago •via X (Twitter)

10 Comments

codeagencybe's profile picture
codeagencybe2 years ago

1. Cache results with (redis Alternative) to avoid re-query same data over and over 2. Use to index results for blazing fast filtering and fuzzy searching

Lee Robinson's profile picture
Lee Robinson2 years ago

If you're trying to avoid re-querying, you can use the built-in React cache() function.

Shubham Saurabh's profile picture
Shubham Saurabh2 years ago

Nice demo Lee! By changing page=-1 in params, it’s throwing some error saying “database does not have a books table”.

Lee Robinson's profile picture
Lee Robinson2 years ago

You're hired for the QA team 🤣

obnol's profile picture
obnol2 years ago

looks like the `[id]` page cant be found, try to refresh on the page directly

Lee Robinson's profile picture
Lee Robinson2 years ago

Nice, good catch. Let me fix this.

codeagencybe's profile picture
codeagencybe2 years ago

Here's An example with typesense with 28 millions books:

Rob Funcken's profile picture
Rob Funcken2 years ago

Nice work Lee. I’m working on a feature that needs this and will look at your implementation for inspiration. I saw that the pagination bar is not showing up on iOS, maybe something with vheight?

Lee Robinson's profile picture
Lee Robinson2 years ago

Ahhh yes, if you scroll futher it's there. It's the Safari viewport differences, I will fix.

Joel Hooks's profile picture
Joel Hooks2 years ago

love seeing the examples Lee. it's a huge help.

Related Videos

Hamas leader Khaled Mashal: “We do not accept the two state solution.” — January 22, 2024 “I would like to say two things about the two-state solution. First, we have nothing to do with the two-state solution. We reject this notion, because it means you would get a promise for a [Palestinian] state, yet you are required to recognize the legitimacy of the other state, which is the Zionist entity. This is unacceptable. We demand to be liberated, to get rid of the occupation, and to have our independence, and our state. [Israel] is my enemy. It is not my concern." “Obviously, the position of Hamas, and the position of the vast majority of the Palestinian people, especially following October 7, I believe that the dream and the hope for Palestine from the River to the Sea, and from the north to the south, has been renewed. This has also become a slogan chanted in the U.S., and in western capital cities, by the American and Western public.” “Hamas agreed to a completely independent (Palestinian) state, with the 1967 borders, with Jerusalem as its capital, with the Right of Return included without recognizing the legitimacy of the Zionist entity. This position was meant to facilitate Palestinian and Arab agreement at this stage, but without relinquishing any of our rights or any part of our land, and without recognizing Israel. Our vision remains unchanged. I believe that October 7 has enhanced this conviction, has narrowed the disagreements, and has turned the idea of liberating Palestine from the River to the Sea into a realistic idea that has already begun. It is not something merely to be expected or hoped for, It is part of the plan, part of the agenda, and we are standing on its threshold, Allah willing.” TRANSLATED BY MEMRI Source:

dan linnaeus

96,479 views • 2 years ago

React tip: "use client" misconceptions (2/5) 🚫 "You cannot nest Server Components inside Client Components because "use client" turns everything into Client Components." ✅ We can pass the rendered result of Server Components to Client Components as props. Simple example: (Server Component) (Client Component) (Server Component) is designed for the client. It needs to instantly open and close when clicked. is designed for the server. It uses packages that don't work in the browser and needs to fetch data close to where it's stored without exposing credentials. So, how can we nest a component that uses server APIs inside a component that uses client APIs... without using `import`? React props to the rescue! --- (0:00) 1-4: Reminder: Importing code forms a module dependency graph. Adding dependencies to a server or client bundle. (0:23) 5-6: Reminder: Using components eventually forms a rendered component tree. (0:37) 9: Oh no! We get an error when trying to `import` a client API (useState) into a server module. (0:44) 10: We know the trick by now: Add "use client" to mark `2.js` as a client entry point. This moves the module to the client bundle and allows us to use client APIs like `useState.` (0:51) 11: But we get a new error! "use client" moved all imported dependencies into the client bundle, including our ORM package, which doesn't work in the browser. (0:59) 13: Let's refactor without changing our rendered component hierarchy. First, we move the `Cart` import to the parent file that imports `Modal`. This moves `Cart` outside the "use client" boundary and consequently the client bundle. (1:11) 15: Then, we pass down the rendered result of `Cart` as a prop to `Modal`. This allows `Cart` to be entirely rendered on the server as a Server Component before being passed down. `Modal` has no knowledge of what the `cart` prop is. Its only responsibility is placing whatever it receives into the `{cart}` slot. (1:15) 16: Finally, it's common to use the special `children` prop for a component's primary content. The key insight is that we were able to use props to retain our desired component hierarchy even though we changed our module dependency graph.

Delba

43,989 views • 2 years ago

The House of Reps has passed second reading of a constitutional amendment bill to remove immunity from the Vice President, the Governors, and their Deputies in order to curb corruption, eradicate impunity, and enhance accountability in public office, along with 41 other bills. The others bill are: A Bill for a Creating Additional Three States Oke - Ogun State, ljebu State and Ife - ljesa State. A Bill for the Creation of "Tiga State" from the Present Kano State with Headquarters in "Rano". A bill to Create a New State in the South Eastern Region of Nigeria Known as Orlu State. A bill to Create an Additional State in the South East Region of Nigeria, Carved from the Existing Five (5) States to be known as Etiti State with Capital at Okigwe. A Bill to Establish and Provide Roles for Traditional Rulers in Nigeria and Provide for the Recognition of the Advisory Role of Traditional Rulers in the Constitution. A bill to Grant Citizenship Rights to Spouses of Women from Nigeria, Specify the Minimum Number of Youths and Women that May be Appointed into Specific Offices. A bill to Guarantee Indigene Status to Persons by Reason of Birth or Continued Residence for a Period of Not Less than Ten Years or by Reason of Marriage. A bill to include Citizenship by Investment as one of the classes of Citizenship in Nigeria, provides for the Acquisition of Nigerian Citizenship by Qualified Foreign Investors who meet Specified Investment Thresholds. A bill to Separate the Offices of the Attorney-General of the Federation, Attorney-General of a State from the Offices of the Minister of Justice of the Federal Government and Commissioner for Justice of the Government of a State. A bill to Provide for the Establishment of the Office of the Accountant-General of the Federation and the Office of the Accountant-General of the Federal Government. A bill to Increase the Number of Members of the Federal Civil Service Commission to Provide for each State of the Federation and Federal Capital Territory, Abuja the Opportunity of One Person Representation. A bill to Mandate all Government Statutory Corporations, Commissions, Authorities, Agencies including all Persons and Bodies Established by Law to Submit Yearly Financial Statement to the Auditor General within a Specified Period. A bill to Specify the Period for the Laying of Annual Budget Estimates Before the National and State Houses of Assembly. A bill to Provide for the Public Disclosure of Reports of the Auditor-General of the Federation and for the Auditor-General of a State. And others constitutional amendments.

Imran Muhammad

116,014 views • 1 year ago

The IDF has Launched a Preemptive Strike Against Iran's Nuclear Program, Israeli military spokesperson Effie Defrin: For years, the Iranian regime has been waging a direct and indirect campaign of terror against the State of Israel, by funding and directing terrorist activities via its proxies across the Middle East, while advancing toward obtaining a nuclear weapon. The Iranian regime is at the head of the axis responsible for all terrorist attacks against the State of Israel since the beginning of the "Swords of Iron" War, including by arming and funding the Hamas terror organization which was responsible for the October 7th Massacre. During the "Swords of Iron" War, Iran even directly attacked Israel twice, firing hundreds of missiles toward the State of Israel. The Iranian regime has proclaimed that its objective is to destroy the State of Israel. Senior officials in the Iranian regime have publicly declared their intent to destroy Israel, and are operating to achieve this together with their proxies in the Middle East. Today, Iran is closer than ever to obtaining a nuclear weapon. Weapons of mass destruction in the hands of the Iranian regime are an existential threat to the State of Israel and a significant threat to the wider world. The State of Israel will not allow a regime whose objective is to destroy the State of Israel to obtain weapons of mass destruction. The IDF has conducted a process of preparations for a campaign on the frontline and on the home front. The resilience of Israel's citizens will be an important factor of the campaign. The IDF is ready to continue to act as required. The State of Israel has the obligation to act in defense of its citizens and will continue to do so everywhere it is required to do so, as we have done in the past.

Joe Truzman

15,336 views • 1 year ago