Clerk Webpack Importing Error

I'm trying to use the useUser() function provided with Clerk, however I'm getting this error whenever I try to compile it:
Unhandled Runtime Error

Error: (0 , _clerk_nextjs__WEBPACK_IMPORTED_MODULE_1__.useUser) is not a function
Unhandled Runtime Error

Error: (0 , _clerk_nextjs__WEBPACK_IMPORTED_MODULE_1__.useUser) is not a function
Here's the code:
import { UserButton, useUser } from "@clerk/nextjs";

const Sidebar = () => {
const user = useUser();

return (
<header
className="..."
>
<div className="...">
<h1>Work in Progress</h1>
</div>

<div className="..."></div>

<div className="...">
<UserButton afterSignOutUrl="/" />
<h2 className="...">Welcome, {user?.fullName}</h2>
</div>
</header>
);
};

export default Sidebar;
import { UserButton, useUser } from "@clerk/nextjs";

const Sidebar = () => {
const user = useUser();

return (
<header
className="..."
>
<div className="...">
<h1>Work in Progress</h1>
</div>

<div className="..."></div>

<div className="...">
<UserButton afterSignOutUrl="/" />
<h2 className="...">Welcome, {user?.fullName}</h2>
</div>
</header>
);
};

export default Sidebar;
Solution:
Add "use client" works on my case Thanks for the reply man! 🤝...
Jump to solution
4 Replies
Shiielty
Shiielty6mo ago
Hi, did you find the solution for this? I have the same problem when code along with theo's T3 video
General Mudkip
General Mudkip6mo ago
Yes, but I'm not entirely sure what fixed it. Here's what looks different from my old code; - const { user } = useUser(); - "use client" directive at the top - if (!user) { return null } before the actual return statement Hopefully that fixes it for you
Solution
Shiielty
Shiielty6mo ago
Add "use client" works on my case Thanks for the reply man! 🤝
General Mudkip
General Mudkip6mo ago
No problem!
Want results from more Discord servers?
Add your server
More Posts
Why can't I extend the user session object?I'm using the drizzle t3 stack but unable to get this to work! I want to add a new key to the user tRPC query has any typeI'm using turbo repo for **trpc (with express) and react-native**, I made mutation query, but in cliI MUST BE DOING SOMETHING WRONG Prismadb + TypescriptI MUST BE DOING SOMETHING WRONG Prismadb + Typescript I have been "playing" with typescript this weCaching Images Next.jsSomeone that has any good ideas / thoughts on how to use caching of images well in Next.js? Should aDoes anyone know how to speed up presigning S3 URLs?I'm working on a toy project where users upload content, and I noticed that it takes forever to loadHow to perform 2 trpc queries, when I need the second query to rely on data from the first?Sorry for making the title so complex What I need is simple. I need to make 2 requests but get some Inferred Type Parameter from a Fixed Union is Different from a Parameter that is a Fixed UnionSo this took me embarrassingly long to figure out how to articulate, hoping it saves someone a lot oHow to dynamically display iconsSo in my app i want to dynamically display icons from a `string[]` but it doesn't seem to want to woPrisma Two of the same model inside of a model```prisma // This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/Is it possible to pass access tokens to react server components?I have an access token that's stored in local storage. Using the access token in client components i