Skip to Content
Docs
SDK guides

The framework bindings

The React, Next.js and Vue bindings for pontkit's web components: Provider, hooks, widgets and their events.

The bindings wrap @pontive/pontkit-core's elements (pont-*), which the loader fetches from the CDN at the release the platform decides.

PackageWhat
@pontive/pontkit-reactProvider, the hooks and control components, the widget wrappers
@pontive/pontkit-nextjs. re-exports @pontive/pontkit-react; ./server is the auth proxy and server sessions
@pontive/pontkit-vuethe loader plugin, isPontElement, PONT_ELEMENTS and the element types
@pontive/pontkit-loaderresolves the release (/v1/frontend/runtime-config), loads its module and stylesheet with SRI

Core never imports the auth SDK: <pont-provider> is given one (sdk). The React Provider injects Auth from @pontive/oidc-client (a dependency of @pontive/pontkit-react); Vue and plain pages set it themselves.

React

import {
  Provider, SignedIn, SignedOut, Signin, AccountMenu,
  OrganizationSwitcher, useAuthState,
} from "@pontive/pontkit-react";

export function App() {
  return (
    <Provider
      appId="app_123"
      domain="/__pontive"                       // the auth proxy, or the auth hostname
      apiBaseUrl="https://api.us.pontive.com"   // the account widgets' gateway
      signinUrl="/sign-in"
      signinRedirectUrl="/app"
      onRedirect={(e) => { e.preventDefault(); router.push(e.detail.url); }}
    >
      <SignedOut><Signin fallback={<Spinner />} /></SignedOut>
      <SignedIn>
        <OrganizationSwitcher onOrganizationChanged={(e) => reload(e.detail.organizationId)} />
        <AccountMenu accountSettingsUrl="/account" />
      </SignedIn>
    </Provider>
  );
}

Provider

Renders <pont-provider> and does the one thing the element can't: it injects the SDK. By default that is Auth from @pontive/oidc-client, installed with this package, so an app that imports the same package shares one instance. Pass sdk to use another client.

Its props are the element's inputs, as properties: appId, domain (required), locales, signinUrl, signupUrl, invitationUrl, signinRedirectUrl, continueHereUrl, scope, organizationId, apiBaseUrl, loginHint, autoRedirect, theme, headers, accountClient, config (your own SDK callbacks, chained after the provider's; never call Auth.configure() yourself), sdk. See pontkit-core docs/kit/provider.md.

Hook / component
useAuthState(){ isAuthenticated, resolved }, from pont-auth-changed (seeded from .auth)
useSession()the last pont-session-changed ({ reason, source, isAuthenticated, organizationId }), or null
useSdk()the injected SDK
useAccountClient()the account client the widgets use (effectiveAccountClient), or undefined until the SDK is configured; for the calls an app makes beside them, such as listBillingAccounts() and listMyContracts() to choose between Checkout and BillingPortal
SignedIn, SignedOut, AuthResolvedbranch on useAuthState(); nothing until resolved (or fallback)
Authenticatedchildren for a signed-in user; others go to redirectUrl or the provider's signinUrl (onRedirect for a router)

These are React components, not wrappers over <pont-signed-in> / <pont-signed-out>: those detach their children, which React must keep owning.

Widgets and their events

Signin, Signup, Invitation, Consent, AccountMenu, OrganizationSwitcher, AccountSettings, MemberManagement, Checkout, BillingPortal. The two billing widgets are beta: they need the instance's billing capability, the pontive:billing:read and pontive:billing:pay scopes and refresh tokens (pontkit-core docs/kit/checkout.md and docs/kit/billing-portal.md). Props are assigned as element properties once the element is defined. fallback (a placeholder until the first screen) is offered only by the flow widgets (Signin, Signup, Invitation), the elements that honour [part="fallback"].

Every pont-* event an element fires is a callback prop: drop pont-, camel-case, prefix on. The callback gets the event itself, so event.detail is the payload and a cancelable event can be cancelled with event.preventDefault().

ElementEventPropCancel it to
providerpont-auth-changedonAuthChanged
pont-locale-changedonLocaleChanged
pont-session-changedonSessionChanged
pont-redirectonRedirectnavigate with your router
signin, signup, invitationpont-flow-responseonFlowResponse
account menupont-account-settingsonAccountSettingsnavigate yourself
pont-logoutonLogoutsign out yourself
pont-menu-item-clickonMenuItemClickstop the item's own action
pont-open-changeonOpenChangekeep the menu as it is
organization switcherpont-organization-changedonOrganizationChanged
pont-organization-switch-failedonOrganizationSwitchFailed
pont-open-changeonOpenChange
account settingspont-profile-updatedonProfileUpdated
pont-authorized-app-revokedonAuthorizedAppRevoked
pont-open-changeonOpenChange
member managementpont-members-invitedonMembersInvited
pont-member-roles-updatedonMemberRolesUpdated
pont-member-removedonMemberRemoved
pont-invitation-resentonInvitationResent
pont-invitation-revokedonInvitationRevoked
checkoutpont-checkout-completedonCheckoutCompletedstay on the page or route yourself
pont-checkout-cancelledonCheckoutCancelledhandle Cancel yourself
billing portalpont-billing-contract-changedonBillingContractChanged
pont-billing-contract-cancelledonBillingContractCancelled
pont-billing-cancellation-revokedonBillingCancellationRevoked
pont-billing-invoice-paidonBillingInvoicePaid
pont-billing-payment-method-addedonBillingPaymentMethodAdded
pont-billing-payment-method-default-changedonBillingPaymentMethodDefaultChanged
pont-billing-payment-method-removedonBillingPaymentMethodRemoved

Note the switcher's prop is onOrganizationSwitchFailed (the event's name), called with the event. The element also has an onSwitchFailed / onOrganizationChanged property taking the detail; the binding listens for the events instead and never sets those properties.

Next.js

@pontive/pontkit-nextjs re-exports @pontive/pontkit-react. The components use hooks, so mount them from a client component ("use client"). They import and server-render safely: the tags go out empty and upgrade when the bundle loads.

domain="/__pontive" goes through the auth proxy (createAuthProxy), which forwards /v1/frontend, /v1/me and /oauth2, so the provider's runtime-config, widget-messages and theme reads, and the signed-in user's own /v1/me calls (profile, sessions, memberships, billing), go through it too. Organization management does not: apiBaseUrl must be the absolute regional API URL (https://api.us.pontive.com, whose routes are under /v1; the default account client refuses anything else), read for example from a NEXT_PUBLIC_ variable.

Vue

Vue needs no wrappers: it mounts custom elements and passes properties and listens for events itself. Tell the compiler to leave the tags alone, and set the provider's SDK:

import { createApp } from "vue";
import PontKit, { isPontElement } from "@pontive/pontkit-vue";

app.config.compilerOptions.isCustomElement = isPontElement; // every pont-* tag
app.use(PontKit);
<pont-provider ref="provider" app-id="app_123" domain="/__pontive">
  <pont-account-menu @pont-logout="onLogout" />
</pont-provider>
<!-- onMounted: provider.value.sdk = Auth   (import { Auth } from "@pontive/oidc-client") -->