Back to Blog
·11 min

How to Build a Nonprofit Donation Platform

Nonprofits need technology to accept donations, manage donors, track campaigns, and report impact. Building a donation platform requires careful attention to payment processing, receipt generation, and donor communication.

In this guide, we will build a donation platform using Next.js, Prisma, and Stripe. Donors can make one-time or recurring donations, view impact reports, and receive tax receipts.

Database Schema

model Campaign {
  id          String   @id @default(cuid())
  name        String
  description String?
  goal        Decimal
  raised      Decimal   @default(0)
  startDate   DateTime
  endDate     DateTime?
  active      Boolean   @default(true)
  donations   Donation[]
}

model Donation {
  id          String   @id @default(cuid())
  amount      Decimal
  donorId     String?
  donor       Donor?   @relation(fields: [donorId], references: [id])
  campaignId  String?
  campaign    Campaign? @relation(fields: [campaignId], references: [id])
  recurring   Boolean  @default(false)
  status      String   @default("completed")
  receiptUrl  String?
  createdAt   DateTime @default(now())
}

model Donor {
  id            String     @id @default(cuid())
  email         String
  name          String?
  totalDonated  Decimal    @default(0)
  donations     Donation[]
  createdAt     DateTime   @default(now())
}

Campaign Progress Component

function CampaignCard({ campaign }: { campaign: Campaign }) {
  const progress = Number(campaign.raised) / Number(campaign.goal) * 100

  return (
    <div className="rounded-xl bg-gray-900 p-6">
      <h3 className="text-lg font-bold text-white">{campaign.name}</h3>
      <p className="mt-1 text-sm text-gray-400">{campaign.description}</p>

      <div className="mt-4">
        <div className="flex items-center justify-between text-sm">
          <span className="text-gray-400">Raised: <span className="text-white font-semibold">${campaign.raised}</span></span>
          <span className="text-gray-400">Goal: <span className="text-white">${campaign.goal}</span></span>
        </div>
        <div className="mt-2 h-2 rounded-full bg-gray-800">
          <div className="h-2 rounded-full bg-brand-600 transition-all" style={{ width: `${Math.min(progress, 100)}%` }} />
        </div>
        <p className="mt-1 text-xs text-gray-500">{Math.round(progress)}% of goal</p>
      </div>

      {campaign.endDate && (
        <p className="mt-3 text-xs text-gray-500">
          {new Date(campaign.endDate) > new Date()
            ? `${Math.ceil((new Date(campaign.endDate).getTime() - Date.now()) / (1000 * 60 * 60 * 24))} days left`
            : 'Campaign ended'}
        </p>
      )}
    </div>
  )
}

Donation Processing with Stripe

import { NextRequest, NextResponse } from 'next/server'
import Stripe from 'stripe'

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!)

export async function POST(req: NextRequest) {
  const { amount, campaignId, recurring, donorEmail } = await req.json()

  const paymentIntent = await stripe.paymentIntents.create({
    amount: Math.round(amount * 100),
    currency: 'usd',
    metadata: { campaignId, donorEmail },
    ...(recurring ? { setup_future_usage: 'off_session' } : {}),
  })

  return NextResponse.json({ clientSecret: paymentIntent.client_secret })
}

Impact Report Visualization

Displaying impact converts donors and drives recurring giving. Show metrics like meals served, children educated, trees planted — tied to donation amounts. A simple bar chart showing monthly donations with year-over-year comparison makes the impact tangible.

Cross-Selling: Launch Your Donation Platform

Our Nonprofit Donation Hub template provides a complete donation platform with customizable forms, donor management, recurring donations, campaign tracking, tax receipts, and impact reports. Everything a modern nonprofit needs to raise funds online.

Combine with Event Management for fundraising events, or Email Campaign Manager for donor communication and newsletters. The entire ecosystem works together to support nonprofit operations.

Ready to Build?

Get started with our production-ready starter kits and ship your project faster.

Browse Starter Kits