Back to cookbook

AI Prompt to Build a React Billing Dashboard Component Using Stripe's MCP Server

0 views Published

Make this prompt yours

Share

This prompt is for frontend developers who need to build a React billing dashboard component that shows a customer's live subscription, invoices, and payment method, pulled directly through Stripe's MCP server instead of hand-rolling API calls and state management for each piece. The model uses the MCP connection to fetch real account data, then generates a typed React component that renders it.

The tricky part of this kind of component isn't fetching the data, it's handling the states around it: a card that's about to expire, an invoice that's past due, a subscription that's been canceled but is still active until period end. A prompt that only asks for a happy-path "show the plan and the next charge date" component will produce something that breaks the first time a real customer's billing data is messy, so it's worth being explicit about every state the component needs to render, not just the default one.

This pattern fits any SaaS account settings page, admin tool, or internal support dashboard where someone needs to see a customer's billing status at a glance. Since this is both a data-fetching and a UI-states problem, running the finished prompt through the Prompt Optimizer in Coding mode is a reasonable next step to tighten the component requirements before handing it to a model.

Prompt template

Make this prompt yours

prompt-template
241 tokens
ROLE: You are a senior React/TypeScript developer building a billing dashboard component for a SaaS product. CONTEXT: The component should display billing data for a customer, retrieved via Stripe's MCP server: [LIST_DATA_NEEDED_E.G._SUBSCRIPTION_PLAN_NEXT_CHARGE_DATE_PAYMENT_METHOD_RECENT_INVOICES] Framework/styling: [REACT_VERSION_AND_STYLING_APPROACH_E.G._TAILWIND_CSS_MODULES] CONSTRAINTS: - Handle these billing states explicitly: [LIST_STATES_E.G._ACTIVE_PAST_DUE_CANCELED_PENDING_NO_PAYMENT_METHOD] - Show a loading skeleton while data is being fetched, and a clear error state if the fetch fails - Format currency and dates using the customer's actual locale/currency, not a hardcoded format - Separate the data-fetching hook from the presentational component OUTPUT FORMAT: 1. A short explanation of the component's structure (hook + presentational component) 2. The full TypeScript code, in a single fenced code block, with comments marking where each billing state is handled 3. A one-line note on any assumption you made about the data shape returned by the MCP server

Want it sharper? Optimize this prompt with Prompt Optimizer, check it with the Prompt Debugger or shorten it with the Token Optimizer.

Example input

example-input
238 tokens
ROLE: You are a senior React/TypeScript developer building a billing dashboard component for a SaaS product. CONTEXT: The component should display billing data for a customer, retrieved via Stripe's MCP server: current plan name, subscription status, next charge date and amount, default payment method (brand + last 4 digits), and the last 3 invoices with their status. Framework/styling: React 18 with Tailwind CSS. CONSTRAINTS: - Handle these billing states explicitly: active, past_due, canceled (but active until period end), and no payment method on file - Show a loading skeleton while data is being fetched, and a clear error state if the fetch fails - Format currency and dates using the customer's actual locale/currency, not a hardcoded format - Separate the data-fetching hook from the presentational component OUTPUT FORMAT: 1. A short explanation of the component's structure (hook + presentational component) 2. The full TypeScript code, in a single fenced code block, with comments marking where each billing state is handled 3. A one-line note on any assumption you made about the data shape returned by the MCP server

When to use it

  • You're building an account settings or billing page that needs to show live subscription and invoice data from Stripe
  • You want the component to come from the model with proper TypeScript types and loading/error states already handled, not just a happy-path render
  • You're building an internal support tool where an agent needs to see a customer's billing status without opening the Stripe dashboard separately
  • You need the same billing UI pattern reused across multiple customer-facing or internal pages and want a consistent starting component

Best practices

  • Specify every billing state the component must handle: active, past due, canceled-but-active-until-period-end, and no payment method on file
  • Ask for loading and error states explicitly, since a live Stripe-backed component will hit both in production
  • Require currency and date formatting to be explicit (locale, currency code) rather than left to default string interpolation
  • Separate the data-fetching logic from the presentational component so the UI can be tested or reused with mock data

Common mistakes

  • Only asking for the happy-path "active subscription" view and leaving past-due or canceled states unhandled
  • Hardcoding currency formatting instead of using the customer's actual currency from the Stripe data
  • Not asking for a loading skeleton, so the component flashes empty content while the MCP call resolves
  • Mixing data-fetching and rendering in one component, making it hard to reuse or test independently

FAQs

How does Stripe's MCP server work with a React component like this?

The MCP server exposes Stripe account data (subscriptions, invoices, payment methods) as a callable tool. In this pattern, a data-fetching hook calls that tool to get the customer's current billing data, and a separate presentational component renders it, so the component itself doesn't need direct Stripe API integration code.

What billing states does a React billing dashboard actually need to handle?

At minimum: an active subscription, a past-due payment, a canceled subscription that's still active until the period ends, and no payment method on file. Each needs its own visible state in the UI rather than being silently treated the same as "active."

Why does the prompt separate the data-fetching hook from the presentational component?

Separating them means the presentational component can be tested or demoed with mock data without needing a live Stripe/MCP connection, and the same hook can be reused if the billing data needs to appear in more than one place in the app.

Can this same prompt pattern be adapted for a different payment provider?

Yes. The component structure and the list of billing states to handle stay the same; only the data-fetching hook and the shape of the data it returns would change for a different provider's API or MCP server.

What tool can help me tighten this prompt before giving it to a model?

Prompt Optimizer — its Coding mode is built for turning a rough component description into a structured prompt with clear constraints, which helps make sure every billing state and output requirement is spelled out before the model writes the code.

Found this prompt useful? Share it.

Share

More in React Prompt Recipes

React Prompt Recipes

AI Prompt to Build a React Dark Mode Toggle with System Preference Detection

A React dark mode toggle prompt asks ChatGPT, Claude, or Gemini to generate a theme switching component that respects the user's OS level li…

Role: You are a senior React developer building a reusable UI component.

Context:
Framework/setup: [REACT VERSION, e.g. React 18 with Vite, Next.js App Router]
Styling approach: [CSS variables / Tailwind CSS dark class / CSS-in-JS library]
Component location/usage: [where the toggle will live, e.g. app header, settings page]

Task:
Build a dark mode toggle component with this exact behavior:
1. On first load, detect the user's OS preference via the `prefers-color-scheme` media query and use it as the initial theme, applied before the main content paints (no flash of the wrong theme).
2. If the user has previously made an explicit choice, that stored choice overrides the OS preference on future visits.
3. Persist the user's explicit choice in [STORAGE MECHANISM, e.g. localStorage].
4. Listen for theme changes made in other open tabs and update this tab's theme to match.
5. Expose the current theme and a toggle function via [CONTEXT/HOOK NAME, e.g. a useTheme hook] so other components can read and react to it.

Constraints:
- Use [STYLING APPROACH] to apply the theme, not inline style objects
- Include accessible labeling (aria-label or visible text) that reflects the current state
- Keep the component dependency-free unless [ALLOWED LIBRARIES] are specified

Output format:
Return the full component code in a fenced code block, followed by a short usage example showing how to wrap the app and consume the hook elsewhere.

Make this prompt yours

React Prompt Recipes

AI Prompt to Build a React Kanban Board With Drag-and-Drop

This prompt gives ChatGPT, Claude, or Gemini a complete specification for building a React Kanban board with drag and drop column reordering…

You are a senior React developer specializing in accessible, production-ready UI components.

Context:
- Framework: [REACT VERSION, e.g. React 18 with TypeScript]
- Drag-and-drop library: [LIBRARY NAME, e.g. @dnd-kit/core]
- Styling approach: [e.g. Tailwind CSS, CSS Modules, styled-components]
- Columns or workflow stages: [LIST OF COLUMN NAMES, e.g. Backlog, In Progress, Review, Done]
- State source: [e.g. local state, Zustand store, REST API endpoint]

Build a Kanban board component with the following requirements:
1. Render one column per workflow stage listed above, each showing its card count
2. Support dragging cards between columns and reordering cards within a column
3. Support keyboard-based reordering, not mouse-only interaction, for accessibility
4. Identify cards by a stable [ID FIELD NAME] field, never by array index
5. Call a [CALLBACK NAME] function on every successful move, passing the card id, source column, destination column, and new index
6. Show an optimistic UI update immediately, then roll back if [CALLBACK NAME] rejects
7. Handle empty columns and drops outside any valid column gracefully

Output format:
- The main board component
- Column and Card subcomponents
- Any custom hooks used for drag state
- A short usage example showing how to wire [CALLBACK NAME] to a real API call
- Brief notes on any library-specific setup required, such as providers, context, or CSS imports

Make this prompt yours

React Prompt Recipes

AI Prompt for an Accessible React Autocomplete Combobox

This prompt is for developers asking Claude , ChatGPT , or Gemini to generate a React autocomplete combobox component, the input plus dropdo…

Generate a React component with the following specification.

ROLE
- You are a frontend engineer who writes accessible, production-ready React components.

COMPONENT
- A searchable autocomplete combobox named [COMPONENT NAME].
- Props: options ([OPTION SHAPE, e.g. array of {id, label}]), value, onChange, placeholder.
- Controlled component: value and onChange are provided by the parent; do not manage selected value as internal-only state.

ACCESSIBILITY REQUIREMENTS
- Use the ARIA 1.2 combobox pattern: role="combobox" on the input, role="listbox" on the options container, role="option" on each item, and aria-activedescendant to track the highlighted option.
- Support keyboard interaction: ArrowDown/ArrowUp to move highlight, Enter to select the highlighted option, Escape to close the list, Home/End to jump to first/last option.
- Announce the number of matching results to screen readers when the list updates.

BEHAVIOR
- Filter options client-side, debounced by [DEBOUNCE MS, e.g. 150]ms.
- Close the dropdown on click outside or on Escape.
- If no options match, display [EMPTY STATE MESSAGE] inside the listbox instead of hiding it.

OUTPUT FORMAT
- A single functional component using hooks, written in [TYPESCRIPT OR JAVASCRIPT], with inline comments marking each accessibility feature.

Make this prompt yours