Search code examples
reactjstypescriptnext.jsclerk

Clerk Bug: UserResource type from useUser() and @clerk/types do not match


I tried to pass the user coming from useUser() but I get the following error:

Type 'UserResource' is missing the following properties from type 'UserResource': passkeys, createPasskey

Upon further investigation I stumbled upon the problem that UserResource type used in useUser() does not include passkeys and createPasskey that is coming from UserResource at @clerk/types

Parent Component:

import { useUser } from "@clerk/nextjs";

export default function Page(props: Props) {
  const { isLoaded, user } = useUser();

  return (
    <>
      ...
          <Form user={user} />
    </>
  );

ChildComponent:

import { UserResource } from "@clerk/types";

type Props = {
  user: UserResource;
};

const Form = ({ user }: Props) => {
...
}

package.json versions

"@clerk/nextjs": "^4.30.1"

"@clerk/types": "^4.2.0"

I tried to update the packages but it didn't work


Solution

  • The User, Organization, and other resources are exported from the @clerk/nextjs/server in the core-2 (>= 5) version.

    import type { User } from '@clerk/nextjs/server';