Next.js Discord

Discord Forum

Calling useUser() in ServerSide component

Unanswered
Rex posted this in #help-forum
Open in Discord
RexOP
Hi, I'm using Clerk for authentication and I was wondering if this GET call is ok or I need to edit it to a POST instead so I can call useUser() in a Client Component:
export const GET = async () => {
  const { user } = useUser();
  if (!user) return;
  const userId = user.id;
  
  try {
    const categories = await prisma.category.findMany({
      where: {
        user_id: userId,
      },
....

0 Replies