File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 378378 title : Cookie limitations in Spaces
379379 - local : spaces-handle-url-parameters
380380 title : Set URL query and hash
381+ - local : spaces-get-user-plan
382+ title : Get User Plan
381383
382384- local : other
383385 title : Other
Original file line number Diff line number Diff line change 1+ # How to get a user's status in Spaces
2+
3+ You can check if a user is logged in or not on the main site, and if they have a PRO subscription or one of their orgs has a paid subscription.
4+
5+ ``` js
6+ window .addEventListener (" message" , (event ) => {
7+ if (event .data .type === " USER_PLAN" ) {
8+ console .log (" plan" , event .data .plan );
9+ }
10+ })
11+
12+ window .parent .postMessage ({
13+ type: " USER_PLAN_REQUEST"
14+ }, " https://huggingface.co" );
15+ ```
16+
17+ ` event.data.plan ` will be of type:
18+
19+ ``` ts
20+ {
21+ user : " anonymoous" ,
22+ org : undefined
23+ } | {
24+ user : " pro" | " free" ,
25+ org : undefined | " team" | " enterprise" | " plus" | " academia"
26+ }
27+ ```
28+
29+ You will get both the user's status (logged-out = ` "anonymous" ` ) and their <a href =" https://huggingface.co/pricing " >plan</a >.
You can’t perform that action at this time.
0 commit comments