`useUser` has a differently typed user object than `currentUser` and `clerkClient.users.getUser`
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- nextjs, react, typescript
调研方向
首先比较报告中指出的 packages/react/src/hooks/useUser.ts 和 packages/nextjs/src/app-router/server/currentUser.ts 中使用的类型。当 useUser().user 和 currentUser() 公开相同的 User 类型(包括 primaryEmailAddress 和 fullName 等属性),并与文档保持一致时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Preliminary Checks
-
I have reviewed the documentation: https://clerk.com/docs
-
I have searched for existing issues: https://github.com/clerk/javascript/issues
-
I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
-
This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.
Reproduction / Replay Link
Publishable key
pk_test_1234567890
Description
When developing with Clerk the user objects returned from useUser() and currentUser() are different. Notably primaryEmailAddress and fullName exists in useUser().user, but doesn't exist in currentUser(). This inconsistency makes it more difficult to create shared utils and generally share things across different parts of our application.
The docs claim that these are the same User object, but that is not accurate.
The currentUser helper returns the User object of the currently active user. This is the same User object that is returned by the useUser hook.
The deviation occurs because useUser from clerk-react users clerk-types/UserResource: https://github.com/clerk/javascript/blob/main/packages/react/src/hooks/useUser.ts#L1
And currentUser uses clerk-backend/User: https://github.com/clerk/javascript/blob/main/packages/nextjs/src/app-router/server/currentUser.ts#L1
Expected behavior:
useUser().user and currentUser() should be the same type
Actual behavior:
They are not the same type
Environment
Not relevant and hard to get correct packages from a mono repo, but here it is for the root:
System:
OS: macOS 14.1
CPU: (12) arm64 Apple M2 Max
Memory: 53.19 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.3.1 - ~/.nvm/versions/node/v20.3.1/bin/node
npm: 9.6.7 - ~/.nvm/versions/node/v20.3.1/bin/npm
pnpm: 8.10.0 - ~/.nvm/versions/node/v20.3.1/bin/pnpm
Browsers:
Chrome: 119.0.6045.159
Safari: 17.1
npmPackages:
@babel/preset-typescript: ^7.22.15 => 7.22.15
@commitlint/cli: ^17.6.7 => 17.6.7
@commitlint/config-conventional: ^17.6.7 => 17.6.7
@knnlabs/configs: workspace:* => 0.0.0
@knnlabs/eslint-config-custom: workspace:* => 0.0.0
@trivago/prettier-plugin-sort-imports: ^4.2.0 => 4.2.0
@turbo/gen: ^1.10.12 => 1.10.12
@types/jest: ^29.5.4 => 29.5.4
bun: ^1.0.3 => 1.0.3
eslint: ^8.46.0 => 8.50.0
husky: ^8.0.3 => 8.0.3
jest: ^29.6.4 => 29.6.4
lint-staged: ^13.2.3 => 13.2.3
prettier: ^3.0.0 => 3.0.0
prettier-plugin-prisma: ^5.0.0 => 5.0.0
turbo: ^1.10.16 => 1.10.16
- 主要语言
- TypeScript
- 星标
- 1.8k
- 派生
- 473
- 平均合并
- 2 天 2 小时
- 30 天内合并 PR
- 253
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
clerk/javascript 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
clerk/javascript#10033 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
clerk/javascript#10026 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
clerk/javascript#9987 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 65/100
clerk/javascript#10011 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 50/100
clerk/javascript#9984 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
external-issue to-triage
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
diegosouzapw/OmniRoute#15401 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
code-yeongyu/oh-my-openagent#9454 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
smart-village-solutions/sva-studio#1654 ·
维护者通常 1 天内回复