Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
2 replies
ibby

nextjs how to render serverside and then update data client-side based on a filter?

I have this page.tsx rendering on the server:

const PostsPage = async () => {
  const posts = await db.post.findMany({
    take: 25,
    include: {
      author: true
    }
  });

  return (
    <div>
      <div>
        <label>Filter verified posts</label>
        <input type="checkbox" ... /> // checkbox to filter posts (add query string?)
      </div>
      
      <div>
        {posts.map(p => (<Post
          key={p.id} 
          id={p.id} 
          content={p.content} 
          authorName={p.author.name} 
        />))}
      </div>
    </div>
  );
};
Was this page helpful?