Next.js Discord

Discord Forum

Server Component which is not supported in the pages/ directory

Unanswered
Da_v_id posted this in #help-forum
Open in Discord
Avatar
I am trying to tweak the Team-switcher component in the 7th Shadcn sidebar to dynamically pull the teams from the server. I am following his steps at https://ui.shadcn.com/docs/components/sidebar#react-server-components, but as soon as import getUserCohorts in this server components the app thrws the error in the picture:

import { getUserCohorts } from "@/queries/cached-queries"
import { SidebarMenu, SidebarMenuItem, SidebarMenuButton } from "./ui/sidebar";

export async function NavCohorts() {
  const projects = await getUserCohorts();

  if (!projects || projects.length === 0) {
    return null;
  }
  return (
    <SidebarMenu>
      {projects.map((project) => (
        <SidebarMenuItem key={project.year}>
          <SidebarMenuButton asChild>
            <a href={project.avatar_url}>
              <div>random</div>
            </a>
          </SidebarMenuButton>
        </SidebarMenuItem>
      ))}
    </SidebarMenu>
  )
}


Am I missing something?
Image

0 Replies