Hub documentation
How to get a user’s plan and status in Spaces
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.