Skip to content
Create account
or
Sign in
The Stripe Docs logo
/
Ask AI
Create account
Sign in
Get started
Payments
Revenue
Platforms and marketplaces
Money management
Developer tools
Overview
Versioning
Changelog
Upgrade your API version
Upgrade your SDK version
Developer tools
SDKs
API
Testing
Workbench
Event Destinations
Workflows
Stripe CLI
Stripe Shell
Developers Dashboard
Agent toolkit
Build with LLMsStripe for Visual Studio CodeStripe health alertsFile uploads
Security and privacy
Security
Privacy
Extend Stripe
Stripe Apps
    Overview
    Get started
    Create an app
    How Stripe Apps work
    Sample apps
    Build an app
    Store secrets
    API authentication methods
    Authorisation flows
    Server-side logic
    Listen to events
    Handle different modes
    Enable sandbox support
    App settings page
    Build a UI
    Onboarding
    Distribute your app
    Distribution options
    Upload your app
    Versions and releases
    Test your app
    Publish your app
    Promote your app
    Add deep links
    Create install links
    Assign roles in UI extensions
    Post-install actions
    App analytics
    Embedded components for Apps
    Embed third-party Stripe Apps
    Migrating to Stripe Apps
    Migrate or build an extension
    Migrate a plugin to Stripe Apps or Stripe Connect
    Reference
    App manifest
    CLI
    Extension SDK
    Permissions
    Viewports
    Design patterns
    Components
      Accordion
      Badge
      Banner
      BarChart
      Box
      Button
      ButtonGroup
      Tickbox
      Chip
      ContextView
      DateField
      Divider
      FocusView
      FormFieldGroup
      Icon
      Img
      Inline
      LineChart
      Link
      List
      Menu
      PropertyList
      Radio
      Select
      SettingsView
      SignInView
      Sparkline
      Spinner
      Switch
      Table
      Tabs
      Tasklist
      TextArea
      TextField
      Toast
      Tooltip
Stripe Connectors
Partners
Partner ecosystem
Partner certification
HomeDeveloper toolsStripe AppsComponents

SettingsView component for Stripe Apps

Let users change details about how the app works with their account.

Copy page

You can define a specialised settings view to let users change specific details about how the app works with their account. For example, an app that uses a third-party API like Zendesk could use SettingsView to authorise a user with their Zendesk account. For more details, learn how to add a settings page for your app.

What SettingsView looks like

SettingsView is a view root component, just like ContextView, containing all other UI elements. It’s the only view that isn’t tied to a specific object, but tied instead to the settings viewport. The settings viewport maps to predefined locations in the Dashboard, outside the app drawer.

SettingsView renders on the app settings page in the Dashboard after you upload an app. While previewing your app locally, you can preview the SettingsView in the Dashboard at https://dashboard.stripe.com/apps/settings-preview.

To use SettingsView, you must add a view with the settings viewport to your app manifest. An application with a settings view would have an app manifest with a ui_extension field that would look something like this:

{ ..., "ui_extension": { "views": [ ..., { "viewport": "settings", "component": "AppSettings" } ], } }

SettingsView props

PropertyType

children

Required

React.ReactNode

The contents of the component.

onSave

Optional

((values: { [x: string]: string; }) => void) | undefined

If provided, a “Save” Button will be rendered with the SettingsView. This callback will be called when the Button is clicked.

statusMessage

Optional

string | undefined

A string to display a status such as “Saved” or “Error” in the header of the view.

Example

This example shows how to fetch settings from an external API, display them, and save changes.

import React from 'react'; import {ExtensionContextValue} from '@stripe/ui-extension-sdk/context'; import {Box, SettingsView, TextField} from '@stripe/ui-extension-sdk/ui'; type FormStatus = 'initial' | 'saving' | 'saved' | 'error'; const AppSettings = ({userContext}: ExtensionContextValue) => { const [storedValue, setStoredValue] = React.useState<string>(''); const [status, setStatus] = React.useState<FormStatus>('initial'); // use the current user id to retrieve the stored value from an external api const key = userContext.id; React.useEffect(() => { if (!key) { return; } const fetchSetting = async (key: string) => { try { const response = await fetch(`https://www.my-api.com/${key}`); const storedSettingValue = await response.text(); if (storedSettingValue) { setStoredValue(storedSettingValue); } } catch (error) { console.log('Error fetching setting: ', error); } }; fetchSetting(key); }, [key]); const saveSettings = React.useCallback(async (values) => { setStatus('saving'); try { const {greeting} = values; const result = await fetch('https://www.my-api.com/', { method: 'POST', body: JSON.stringify(values), }); await result.text(); setStatus('saved'); setStoredValue(greeting); } catch (error) { console.error(error); setStatus('error'); } }, []); const getStatusLabel = React.useCallback(() => { switch (status) { case 'saving': return 'Saving...'; case 'saved': return 'Saved!'; case 'error': return 'Error: There was an error saving your settings.'; case 'initial': default: return ''; } }, [status]); const statusLabel = getStatusLabel(); return ( <SettingsView onSave={saveSettings} statusMessage={statusLabel}> <Box css={{ padding: 'medium', backgroundColor: 'container', }} > <Box css={{ font: 'lead', }} > Please enter a greeting </Box> <Box css={{ marginBottom: 'medium', font: 'caption', }} > Saved value: {storedValue || 'None'} </Box> <TextField name="greeting" type="text" label="Greeting:" size="medium" /> </Box> </SettingsView> ); };

See also

  • Design patterns to follow
  • Style your app
  • UI testing
Was this page helpful?
YesNo
Need help? Contact Support.
Join our early access programme.
Check out our changelog.
Questions? Contact Sales.
LLM? Read llms.txt.
Powered by Markdoc