Next.js Discord

Discord Forum

Can I use Suspense for server components?

Answered
Nelson posted this in #help-forum
Open in Discord
I am using server actions in the child component.
Can I write something like this? Is it work?

const BlogPage = () => {
  return (
    <Suspense fallback='loading comments...'>
      <Comments />
    </Suspense>
  )
}

export default BlogPage


const Comments = async () => {
  const comments = await getComments()

  return (
    // ...
  )
}
Answered by joulev
1. yes the Suspense works
2. no, the getComments is not acting as a server action here, hence don't make it a server action: https://nextjs-forum.com/post/1202186221275861063
View full answer

2 Replies