Get next post in Next/React

I'm trying to link to the next post (if there is one) when on a single post page in my Next.js project. My code below is based on the solution here but I'm not able to get it working.

I query the next news post:
const nextpost = await client.query('document.type', 'news'), { pageSize : 1 , after : ${}, orderings: '[]'})

Then use that query for the link:

<Link as={linkResolver(nextpost)} href={hrefResolver(nextpost)}>
  Next post

Any ideas?

Hey Mike,

Thanks for posting this question. I think it's a great implementation.

What's the repo you're working with? To get started, I'll see if I can get things working on my side.


Mike and I discussed this a bit by DM and found a resolution.

Here is the GitHub repo for the solution, with some instructions for implementation:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.