shadcn Registry Component

Stripe UI Component

A complete file storage solution with Stripe Payment Element and checkout support. Includes payment components, order management, and example pages.

Stripe Payment Element
Next.js 16
Prisma 7
Zustand

Quick Install

Install the stripe-ui component using the shadcn CLI:

Terminal
pnpm dlx shadcn@latest add https://stripe-ui-component.desishub.com/r/stripe-ui-component.json

What's Included

Everything you need for a complete Stripe checkout experience in your Next.js application.

Payment Element
Embedded Stripe Payment Element with automatic card detection, 3D Secure, and multiple payment methods.
Cart & Checkout
Full checkout flow with order summary, shipping address form, and cart integration via Zustand.
Order Management
Order history, order details, payment verification, and status tracking in the dashboard.
API Routes
Server-side payment intent creation, automatic Stripe product sync, and payment verification.

Installation Guide

Follow these steps to add Stripe checkout to your Next.js project.

1Prerequisites

This component requires better-auth-ui (for authentication & Prisma setup) and zustand-cart (for cart state management) to be installed first.

Install better-auth-ui
pnpm dlx shadcn@latest add https://better-auth-ui.desishub.com/r/auth-components.json
Install zustand-cart
pnpm dlx shadcn@latest add https://jb.desishub.com/r/zustand-cart.json

2Install the Stripe UI Component

Install
pnpm dlx shadcn@latest add https://stripe-ui-component.desishub.com/r/stripe-ui-component.json

3Add Prisma Models

Add the following models to your prisma/schema.prisma file. Also add orders Order[] to your User model.

prisma/schema.prisma
model Category {
  id          String    @id @default(cuid())
  name        String
  slug        String    @unique
  image       String?
  description String?
  createdAt   DateTime  @default(now())
  updatedAt   DateTime  @updatedAt
  products    Product[]
}

model Product {
  id              String      @id @default(cuid())
  name            String
  description     String?
  price           Float
  image           String
  stripeProductId String?
  stripePriceId   String?
  categoryId      String?
  category        Category?   @relation(fields: [categoryId], references: [id])
  createdAt       DateTime    @default(now())
  updatedAt       DateTime    @updatedAt
  orderItems      OrderItem[]
}

model Order {
  id              String      @id @default(cuid())
  userId          String
  user            User        @relation(fields: [userId], references: [id])
  status          String      @default("pending")
  paymentStatus   String      @default("unpaid")
  paymentIntentId String?     @unique
  totalAmount     Float
  shippingAddress String?
  items           OrderItem[]
  createdAt       DateTime    @default(now())
  updatedAt       DateTime    @updatedAt
}

model OrderItem {
  id        String  @id @default(cuid())
  orderId   String
  order     Order   @relation(fields: [orderId], references: [id], onDelete: Cascade)
  productId String
  product   Product @relation(fields: [productId], references: [id])
  quantity  Int
  price     Float
}

4Environment Variables

Add your Stripe keys to .env. Get your keys from the Stripe Dashboard.

.env
STRIPE_SECRET_KEY=sk_test_...
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...

5Run Migration & Seed

Generate & Migrate
npx prisma generate
npx prisma migrate dev --name add_stripe_models

Optionally, seed your database with sample products using the included seed file.

6Configure Image Domains

Add your product image domains to next.config.ts.

next.config.ts
const nextConfig = {
  images: {
    remotePatterns: [
      { protocol: 'https', hostname: 'images.unsplash.com' },
      // Add your image domains here
    ],
  },
};

Usage

After installation, these components and pages are ready to use.

Using the ProductGrid component
import { ProductGrid } from "@/components/stripe/product-grid";

// Fetch products from your database
const products = await db.product.findMany({
  include: { category: true },
});

<ProductGrid products={products} />
Using the CheckoutPage component
import { CheckoutPage } from "@/components/stripe/checkout-page";

// The checkout page handles everything:
// - Cart items display with images
// - Shipping address form
// - Stripe Payment Element
// - Payment confirmation & redirect
<CheckoutPage />
Using the OrderHistory component
import { OrderHistory } from "@/components/stripe/order-history";

const orders = await db.order.findMany({
  where: { userId: session.user.id },
  include: { items: { include: { product: true } } },
  orderBy: { createdAt: "desc" },
});

<OrderHistory orders={orders} />

Directory Structure

Files added to your project after installation.

Installed files
components/stripe/
├── stripe-provider.tsx     # Stripe Elements wrapper
├── checkout-form.tsx       # Payment Element form
├── checkout-page.tsx       # Full checkout layout
├── address-form.tsx        # Shipping address inputs
├── order-summary.tsx       # Cart items display
├── order-confirmation.tsx  # Post-payment verification
├── order-history.tsx       # Orders table
├── product-grid.tsx        # Product cards with cart
└── index.ts                # Barrel export

lib/
└── stripe.ts               # Server-side Stripe instance

app/api/stripe/
├── create-payment-intent/
│   └── route.ts            # Create PaymentIntent + Order
└── verify-payment/
    └── route.ts            # Verify payment & update order

app/
├── products/page.tsx       # Product listing page
├── checkout/page.tsx       # Checkout page (protected)
├── order-confirmation/
│   └── page.tsx            # Payment confirmation
└── dashboard/orders/
    ├── page.tsx            # My Orders list
    └── [id]/page.tsx       # Order detail view

Example Pages

Try out the demo pages included with the component.

Products Page
  • Product grid with images & prices
  • Add to cart functionality
  • Category filtering
Checkout Page
  • Stripe Payment Element
  • Shipping address form
  • Order summary with totals
Dashboard
  • Revenue & order stats
  • Order history & details
  • Payment status tracking