Hub documentation

How to get a user’s plan and status in Spaces

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

How to get a user’s plan and status in Spaces

From inside a Space’s iframe, you can check if a user is logged in or not on the main site, and if they have a PRO subscription or if one of their orgs has a paid subscription.

window.addEventListener("message", (event) => {
    if (event.data.type === "USER_PLAN") {
        console.log("plan", event.data.plan);
    }
})

window.parent.postMessage({
    type: "USER_PLAN_REQUEST"
}, "https://huggingface.co");

event.data.plan will be of type:

{
    user: "anonymous",
    org: undefined
} | {
    user: "pro" | "free",
    org: undefined | "team" | "enterprise" | "plus" | "academia"
}

You will get both the user’s status (logged out = "anonymous") and their plan.

Examples

Update on GitHub