Stripe | Financial Infrastructure to Grow Your Revenue

Stripe | Financial Infrastructure to Grow Your Revenue

5282 articles

UI Extension SDK API reference


UI Extension SDK API reference

An index of all fields, types and descriptions for the UI Extension SDK API.

UI extensions have access to context props and utility functions that let them interact with an app’s users and the Stripe Dashboard ecosystem. This page documents these values and functions.

Props

Views are passed props that the extension can use for context on where the extension is being displayed. Your view can take some or all of these props as arguments, and they’re of type ExtensionContextValue.

User context

The userContext prop has data about the end user using your app, including these fields:

FieldTypeExample
namestringJenny Rosen
The app user’s name
account.countrystringUK
The app user’s country
account.idstringacct_1032D82eZvKYlo2C
The app user’s account ID
account.namestringJenny’s Llama Emporium
The name of the Stripe account
account.org_idstringorg_1032D82eZvKYlo2C
The ID of the Stripe organisation the app user belongs to
account.isSandboxBooleantrue
Whether the Stripe account is a sandbox or not
rolesArray< RoleDefinition >none
A list of the active user’s user roles.
localestringen-GB
The app user’s system language ID

RoleDefinition

A role definition has these fields:

Field nameTypeExample
idstringdeveloper
A stable, machine-readable identifier for the user role. Unlike name, this value won’t change when role display names are updated and is safe to use for comparisons.
type‘builtIn’ | ‘custom’builtIn
Specifies the role type. Custom roles are only available to private apps.
namestringDeveloper
Plain language name for the user role. Use id for programmatic comparisons because the name can change.

Environment

The environment prop has data about the page a user is viewing, including these fields:

FieldTypeExample
viewportIDstringstripe.dashboard.payment.list
Current viewport rendering your view
mode‘live’ | ‘test’live
The Stripe API mode the current page is in
objectContext.idstringch_3L0pjB2eZvKYlo2C1u1vZ7aK
In the ObjectView objects, this is the ID of the current object the user views in the Dashboard.
objectContext.objectstringcharge
In the ObjectView objects, this is the type of the current object the user views in the Dashboard.
constantsObject{"the related setting": "https://api.example.com/v1"}
An object with arbitrary constant values passed from the app manifest that can be overridden for local development using the CLI manifest flag.
queryParamsObject{"task": "onboardingStart", "source": "email"}
Query parameters passed to your app either through a route descriptor or a deep link URL. The app_ prefix is removed when passed with the queryParams prop.

OAuth context

The oauthContext prop contains information about the current OAuth workflow, if one is underway.

FieldTypeExample
errorstringnone
OAuth error code
codestringnone
OAuth authorization code
statestringnone
OAuth state used by your app
verifierstringnone
OAuth code verifier

App context

The appContext prop contains information about the user’s app install, and has the following fields:

FieldTypeExample
authorizedPermissionsArray<string>['event_read', 'charge_write']
App’s current authorised permissions
authorizedCSP.connectSrcArray<string>['http://o.ingest.sentry.io/api/']
URLs of permitted third-party APIs. If the URL ends in a slash, all its children are also permitted.
authorizedCSP.imageSrcArray<string>['https://images.example.com/', 'https://images.example.org']
URLs the Img component can load from. If the URL ends in a slash, all of its children are also permitted.

Utility functions

The UI extension SDK provides these functions to help apps interact with the Stripe API, the Dashboard user and Dashboard navigation.

  • clipboardWriteText —Write text to the end user’s clipboard.
  • createHttpClient -Get an authenticated Stripe API client.
  • createOAuthState —Obtain values to use when you create an authorization link in an OAuth workflow.
  • fetchStripeSignature —Get a signature from Stripe’s servers.
  • getDashboardUserEmail —Get the end user’s email address.
  • getUserAuthorizedPermissions – Get the intersection of the app’s authorised permissions and those of the current Dashboard user.
  • isPermissionAuthorized – Indicate whether a permission is currently in an app’s authorised permissions.
  • isSourceInAuthorizedCSP – Indicate whether a URL is currently in an app’s authorised content security policy.
  • navigateToDashboardRoute – Programmatically navigate to a different Dashboard route.
  • showToast —Show a toast message to the user.
  • useRefreshDashboardData – Enable your view to update data in the Dashboard.
  • useStorage —Share data across different viewports of a Stripe App.

clipboardWriteText

Write text to the app user’s clipboard. The user can then paste it as if they had copied it.

ArgumentTypeExample
textstringHello, world!
Text to copy

To use this function, first import it from the SDK:

For example, provide a button that copies Hello, world! to the clipboard when pressed. In a real app, you could use this to copy an address, invoice number, or other important detail.

createHttpClient

Obtain an authenticated Stripe API client for the installed user’s account. You must use the the related setting provided by the SDK to give your client the permissions defined in the app manifest.

To use this function, first import it from the SDK and then provide its values to the Stripe constructor from stripe-node.

For an example in context, see Build a UI.

createOAuthState

Obtain state and challenge values to use when you create an authorisation link in an OAuth workflow.

To use this function, first import it from the SDK.

For an example in context, see Add authorisation workflows.

fetchStripeSignature

Get a signature from Stripe’s servers. Your UI extension can use this signature to send signed requests to your app’s backend.

To use this function, first import it from the SDK.

Caution

In preview mode, the fetchStripeSignature function errors until you complete your first app upload. See server-side logic for setup steps.

For more details and an example in context, see server-side logic docs.

getDashboardUserEmail

Get the app user’s email address.

To use this function, first import it from the SDK.

You must also include the user_email_read permission in your app manifest. Add it using a CLI command or edit the app manifest file directly.

Command Line

Select a language

CLI command

App manifest

No results

stripe apps grant permission user_email_read "EXPLANATION"

For example, access the app user’s email in a view by getting it using the getDashboardUserEmail function and storing it in a React state variable.

getUserAuthorizedPermissions

Gets the intersection of the app’s authorised permissions and those of the current Dashboard user.

For instance, if the app’s current authorised permissions are event_read and charge_write, but the current Dashboard user has a view_only role (that is, no edit permissions), calling the function returns the array ['event_read'].

To use this function, first import it from the SDK.

isPermissionAuthorized

Indicate if a permission is in the app’s authorised permissions. Throws an error if the permission isn’t on the app manifest.

ArgumentTypeExample
permissionstringcharge_read
Permission to check

To use this function, first import it from the SDK.

Gating functionality by permission

This function can gate app functionality by user authorised permissions.

For instance, on the customer details page, only update customer details if the app user has authorised the customer_write permission.

isSourceInAuthorizedCSP

Indicate if a URL is in the app’s authorised connect sources or image sources.

ArgumentTypeExample
sourcestringhttps://images.example.org/
URL to check

To use this function, first import it from the SDK.

Programmatically navigate from a Stripe App to a different Dashboard route. This is useful for navigating the user to a related Dashboard page in response to an in-app action.

Note

navigateToDashboardRoute is only available in SDK version 9.2.0 and later.

ArgumentTypeExample
descriptorRouteDescriptor{name: 'customers'}
A descriptor object specifying the target Dashboard route.

To use this function, first import it from the SDK:

For example, navigate to a specific customer’s details page when a button is pressed:

You can also navigate to your app’s own full-page view by using the fullPage route descriptor:

showToast

Render a toast at the bottom of your view to inform the user about the status of an action. For example, a toast can show a user whether an API call succeeded or failed.

The showToast() function takes two arguments, a message and options. The function is defined as follows:

type ToastType = "success" | "caution" | "pending" | undefined;
type ToastOptions = { type?: ToastType; action?: string; onAction: () => void; }
const showToast: (message: string, options?: ToastOptions) => Promise<{
 update: (updateMessage: string, updateOptions?: ToastOptions) => void;
 dismiss: () => void;
}>;

Toast messages can’t exceed 30 characters in length or be empty. If a message is too long or empty, the console logs an error.

Unless they’re of type pending, toasts dismiss automatically.

Is PendingHas ActionTimeout
falsefalse4s
falsetrue6s
truefalseNone
truetrueNone

Toasts can also prompt the user to take an action. Clicking the action button automatically dismisses the toast.

useRefreshDashboardData

Enable your view to update data in the Dashboard. This function returns another callback function. Store that callback, and call it when Stripe data changes. When you call it, the Dashboard updates to reflect the new values.

To use this function, first import it from the SDK.

For instance, on a customer details page, get the callback function that refreshes Dashboard data, and then call it after updating the current customer.

useStorage

Note

The useStorage React hook is only available in SDK version 9.x.

You can use the useStorage React hook for reading and writing shared data across different viewports of a Stripe App.

This hook synchronises state between all active instances (viewports) of your Stripe App within the same browser. When the value updates in one instance, all other instances in the same browser reflect the change automatically. This is session-based storage that exists only while the app runs.

This hook can help you:

  • Coordinate state between multiple viewports of your app.
  • Avoid redundant API calls by caching fetched data and sharing it across viewports.

The hook has the following limitations:

  • Values are limited to strings, so use JSON. stringify or JSON. parse for complex objects.
  • Storage isn’t persistent between app sessions.
  • Storage changes don’t synchronise between different browsers or devices.

The following example shows how two independently rendered instances of the same app can synchronise the value of a variable across different viewports. Try opening this app in multiple tabs to see how cross-window synchronisation works.

Loading example...

Loading example...

See also

Last verified 2026-09-25

Is this helpful?