|
|
4 месяцев назад | |
|---|---|---|
| .. | ||
| src | 4 месяцев назад | |
| .env.example | 5 месяцев назад | |
| README.md | 5 месяцев назад | |
| eslint.config.js | 5 месяцев назад | |
| jest.config.js | 5 месяцев назад | |
| package.json | 5 месяцев назад | |
| pnpm-lock.yaml | 5 месяцев назад | |
| stripe-app.json | 5 месяцев назад | |
| tsconfig.json | 5 месяцев назад | |
| ui-extensions.d.ts | 5 месяцев назад | |
A Stripe App example demonstrating how to use json-render to build dynamic, AI-generated UI within the Stripe Dashboard.
This example shows how to integrate json-render with Stripe's UI Extension SDK to create dashboard views that can be dynamically generated from prompts. The app includes:
# Install dependencies
pnpm install
# Start the Stripe App in development mode
stripe apps start
The app uses the Stripe UI Extension SDK which handles authentication automatically - no API keys required in your environment.
# Run linting
pnpm lint
# Run tests
pnpm test
Component Catalog: Maps json-render component types to Stripe UIXT components (Box, Button, Badge, etc.)
Action Handlers: Defines actions that can be triggered from the UI (e.g., refundPayment, cancelSubscription)
StripeRenderer: A custom renderer that uses the Stripe component catalog to render json-render specs
Views: Each view fetches data from the Stripe API and renders it using json-render specs
import { StripeRenderer, stripeCatalog } from "./lib/render";
import type { Spec } from "@json-render/react";
const spec: Spec = {
root: "container",
elements: {
container: {
type: "Stack",
props: { direction: "vertical", gap: "medium" },
children: ["heading", "metric"],
},
heading: {
type: "Heading",
props: { text: "Revenue", size: "large" },
children: [],
},
metric: {
type: "Metric",
props: { label: "Total", value: "$12,345", format: "currency" },
children: [],
},
},
};
function MyView() {
return <StripeRenderer spec={spec} catalog={stripeCatalog} />;
}