Overview
The Astro minimal boilerplate provides a ready-to-use starting point for integrating Dodo Payments with your Astro application. This template includes checkout sessions, webhook handling, customer portal, and modern UI components to help you start accepting payments quickly.This boilerplate uses Astro 5 with TypeScript, Tailwind CSS 4, and the
@dodopayments/astro adapter.Features
- Quick Setup - Get started in under 5 minutes
- Payment Integration - Pre-configured checkout flow using
@dodopayments/astro - Modern UI - Clean, dark-themed pricing page with Tailwind CSS
- Webhook Handler - Ready-to-use webhook endpoint for payment events
- Customer Portal - One-click subscription management
- TypeScript - Fully typed with minimal, focused types
- Pre-filled Checkout - Demonstrates passing customer data to improve UX
Prerequisites
Before you begin, make sure you have:- Node.js LTS version (required for Astro 5)
- Dodo Payments account (to access API and Webhook Keys from dashboard)
Quick Start
1
Clone the Repository
2
Install Dependencies
3
Get API Credentials
Sign up at Dodo Payments and get your credentials from the dashboard:
- API Key: Dashboard → Developer → API Keys
- Webhook Key: Dashboard → Developer → Webhooks
4
Configure Environment Variables
Create a Update the values with your Dodo Payments credentials:
.env file in the root directory:5
Add Your Products
Update
src/lib/products.ts with your actual product IDs from Dodo Payments:6
Run the Development Server
Project Structure
Customization
Update Product Information
Editsrc/lib/products.ts to modify:
- Product IDs (from your Dodo dashboard)
- Pricing
- Features
- Descriptions
Pre-fill Customer Data
Insrc/components/ProductCard.astro, replace the hardcoded values with your actual user data:
Update Customer Portal
Insrc/components/Header.astro, replace the hardcoded customer ID with the actual customer ID from your auth system or database:
Webhook Events
The boilerplate demonstrates handling webhook events insrc/pages/api/webhook.ts:
onSubscriptionActive- Triggered when a subscription becomes activeonSubscriptionCancelled- Triggered when a subscription is cancelled
Deployment
This boilerplate uses static output with on-demand rendering for API routes. You’ll need to install an adapter for your deployment platform:| Platform | Guide |
|---|---|
| Vercel | Deploy to Vercel |
| Netlify | Deploy to Netlify |
| Cloudflare | Deploy to Cloudflare |
Update Webhook URL
After deploying, update your webhook URL in the Dodo Payments Dashboard:DODO_PAYMENTS_WEBHOOK_KEY environment variable in your production environment to match the webhook signing key for your deployed domain.
Troubleshooting
Module not found or build errors
Module not found or build errors
Delete
node_modules and reinstall dependencies:Checkout redirect fails
Checkout redirect fails
Common causes:
- Invalid product ID - verify it exists in your Dodo dashboard
- Wrong API key or environment setting in
.env - Check browser console and terminal for errors
Webhooks not receiving events
Webhooks not receiving events
For local testing, use ngrok to expose your server:Update the webhook URL in your Dodo dashboard to the ngrok URL. Remember to update your .env file with the correct webhook verification key.
Customer portal link doesn't work
Customer portal link doesn't work
Replace the hardcoded
CUSTOMER_ID in src/components/Header.astro with an actual customer ID from your Dodo dashboard.Or integrate your authentication system and database to fetch the customer ID dynamically.Build fails with adapter error
Build fails with adapter error
This boilerplate uses static output with on-demand API routes. You need to install an adapter for deployment:See Astro’s deployment guides for details.
Learn More
Support
Need help with the boilerplate?- Join our Discord community for questions and discussions
- Check the GitHub repository for issues and updates
- Contact our support team for assistance