Comments (7)
Hello there - many thanks for the feedback!
Every Clerk package depends on the public @clerk/types
package - if you're using @clerk/nextjs
this will also be installed. Could you try importing UserResource
from @clerk/types
instead? Eg:
import { UserResource } from "@clerk/types";
Your comments about withAuth
/requireAuth
are valid. Improving type support for the nextjs
package was on our roadmap, but let me see if we can publish a first batch of improvements with the next beta release :)
from javascript.
Let me tack on here that the types for withAuth
and requireAuth
are a little messy, both from /nextjs/api
, but also up in /node-sdk
.
At minimum, it would make a big difference if handler: Function
was replaced with the res, req, next
defs from just a few lines down.
Even better would be the generics used over in /nextjs/ssr
so that (1) it could be extended by the nextjs package, and (2) so that session
can be added.
from javascript.
Hi @nikosdouvlis,
Thanks! I can get UserResource
out of types. That said, I do still think it should be exported by the package that uses it.
Similar topic: where's the user and session objects that get passed in when using withServerSideAuth
(e.g. User
)? It's not the same as UserResource
. Maybe a better question: Should they be the same shape?
Thanks again!
from javascript.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.
from javascript.
This issue was closed because it has been stalled for 10 days with no activity.
from javascript.
@mikestopcontinues The objects passed in withServerSideAuth
come from the @clerk/backend
package types. The are 2 different types of resources for user for example, User
and UserResource
.
The User
type is related to the shape generated from an API call from your application server to Clerk server to retrieve an object with information about a user which contains private metadata and other private data that are meant to be used by the server of the application.
The UserResource
is related to the shape generated from the API call from the end-user Browser to the Clerk server to retrieve information based on the end-user session which will not contain private metadata for example.
Based on the above we explicitly use different shapes in the withServerSideAuth
and in the hooks exposed by our packages to mistakenly expose or expect the wrong data.
Example for user
object
- User https://github.com/clerkinc/javascript/blob/6fa67499b9c2ba578be811c35e21124f88facc8b/packages/backend/src/api/resources/User.ts#L7
- UserResource : https://github.com/clerkinc/javascript/blob/6fa67499b9c2ba578be811c35e21124f88facc8b/packages/types/src/user.ts#L47
from javascript.
Thanks, @dimkl. I appreciate the context, and I should've probably closed this issue a while back.
from javascript.
Related Issues (20)
- `useUser` has a differently typed user object than `currentUser` and `clerkClient.users.getUser` HOT 6
- 404 if I want to sign up HOT 7
- authMiddleware.js assertInfiniteRedirectionLoop HOT 7
- Clerk dev failing for latest devices when using device emulation HOT 2
- getToken method returns null right after isSIgnedIn becomes true HOT 3
- "Uncaught Error: Rendered fewer hooks than expected" during signout HOT 1
- Node SDK: `verifyToken` function has wrong signature HOT 1
- Node SDK: `createUser` function missing `createdAt` property HOT 1
- Rendering UserProfilePage fails if UserProfileLink is also used HOT 2
- Endless loop of 401 errors with Remix HOT 5
- Clerk Next.js not edge ready HOT 2
- Clerk doesn't follow `redirect_url` search parameter when refreshing page
- Install clerk package error with pnpm HOT 4
- clerk-expo requires react-dom HOT 2
- `mountSignUp` not loading the locales HOT 11
- [nextjs app router] `ClerkProvider` breaks 404 routing HOT 11
- ClerkProvider + auth + everything not compatible with next PPR (next 14) HOT 4
- Unable to sign-up, turnstile not loaded in cors-friendly way HOT 2
- Infinite Redirect Loop When Home URL is current URL HOT 5
- Infinite redirect loop on same-domain deployments HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javascript.