Simple donation module for Nuxt
A customizable donation component for Nuxt 3 and Nuxt 4 projects, with PayPal integration for configurable one-time donations.
Live demo
You can see it in action at https://wikiherbalist.com/donazioni.
Features
- Compatible with Nuxt 3 and Nuxt 4
- PayPal integration for secure payments
- Customizable donation amounts
- Multilingual support: EN, IT, ES, FR, DE
- Responsive design with Tailwind CSS
- Configurable color scheme via CSS variables
- Custom FAQ sidebar
- XSS protection via DOMPurify sanitization
- Full TypeScript support
Requirements
- Nuxt 3.x or Nuxt 4.x
- Node.js 22.22.3+ or 24.15.0+ (or 26+)
- Tailwind CSS in the host project (the component is styled with Tailwind utility classes)
Tailwind must scan the package files, otherwise the component classes are not generated. With Tailwind CSS 4, add a @source directive to your main CSS file. The path is relative to the CSS file and must point to the node_modules folder in the project root:
/* app/assets/css/main.css (Nuxt 4 default layout) */
@import "tailwindcss";
@source "../../../node_modules/simple-donation/runtime";/* assets/css/main.css (Nuxt 3, or Nuxt 4 without the app/ directory) */
@import "tailwindcss";
@source "../../node_modules/simple-donation/runtime";With Tailwind CSS 3, add the package to content in tailwind.config:
content: ['./node_modules/simple-donation/runtime/**/*.vue']Installation
- Install the package:
npm install simple-donation
# or
yarn add simple-donation- Add the module to your
nuxt.config.tsas described in the Configuration section. - Create a
.envfile in your project root and add your PayPal client ID:
PAYPAL_CLIENT_ID=your_paypal_client_id_hereUsage
Once installed and configured, add the component to any page or component:
<template>
<div>
<h1>Support our project</h1>
<SimpleDonation />
</div>
</template>Configuration
Configure the module in nuxt.config.ts:
export default defineNuxtConfig({
modules: [
['simple-donation', {
paypal: {
clientId: process.env.PAYPAL_CLIENT_ID
},
currency: 'EUR', // ISO 4217 currency code
amounts: [5, 10, 20, 50], // suggested amounts
defaultAmount: 20, // preselected amount
colors: {
primary: '#3B82F6', // main buttons and highlights
secondary: '#1E40AF', // secondary elements
accent: '#60A5FA', // accents and focus states
background: '#FFFFFF' // component background
}
}]
]
})Customization
Language
Use the lang prop to set the component language. Supported values: en, it, es, fr, de. Defaults to en.
<SimpleDonation lang="it" />All UI labels, step names, button text, and default FAQ content will be displayed in the chosen language.
Color scheme
The four color options available are:
primary: main color for buttons and highlightssecondary: used for secondary elements and hover statesaccent: used for accents and focus statesbackground: background color of the component
Custom FAQs
Pass a faqs prop to override the default FAQ items shown in the sidebar:
<template>
<div>
<SimpleDonation lang="it" :faqs="customFaqs" />
</div>
</template>
<script setup>
const customFaqs = [
{
question: 'Come vengono utilizzate le donazioni?',
answer: 'Le donazioni supportano lo sviluppo e la manutenzione del progetto.'
},
{
question: 'Il sistema è sicuro?',
answer: 'Sì, tutte le transazioni utilizzano sistemi con elevati livelli di sicurezza.'
},
{
question: 'Posso fare una donazione ricorrente?',
answer: 'Al momento supportiamo solo donazioni una tantum.'
}
]
</script>Each FAQ item needs a question and an answer property. HTML is allowed and automatically sanitized.
Per-component overrides
currency, amounts and defaultAmount can also be passed as props. Props take precedence over the module configuration.
New in 1.4
- CI checks: lint, npm package contents and a Nuxt 4 playground build
- Configurable
currency,amountsanddefaultAmount success,errorandcancelevents- Optional built-in alerts with
:show-alerts="false" - SSR-safe FAQ sanitization
- Fixed runtime color configuration
- Safe support for multiple component instances on one page
Example:
<SimpleDonation
lang="it"
currency="EUR"
:amounts="[5, 15, 30, 50]"
:default-amount="15"
:show-alerts="false"
@success="handleDonation"
/>Roadmap
See ROADMAP.md for planned improvements, including recurring donations, server-side PayPal verification, headless/compact modes and accessibility work. Continuous integration is now active on GitHub Actions.
Contributing
Contributions are welcome. Feel free to open an issue or submit a pull request on GitHub.
License
This project is open source and available under the MIT License.