NuxtJS module for Stripe.js
- Load Stripe.js only when required
- Reuse the same instance across all components
- TypeScript support
- Add
nuxt-stripejs
dependency to your project:
npm install nuxt-stripejs
- Add
nuxt-stripejs
module and configuration tonuxt.config.js
:
export default {
// ...other config options
modules: ["nuxt-stripejs"];
stripe: {
publishableKey: 'pk_test_XXXXXXXXXXXXXXX',
}
}
- (Optional) TypeScript support. Add
nuxt-stripejs
to thetypes
section oftsconfig.json
:
{
"compilerOptions": {
"types": [
"nuxt-stripejs"
]
}
}
- Type:
String
Your Stripe's publishable key.
It can be used inside components like:
{
async mounted() {
const stripe = await this.$stripe()
const elements = stripe.elements()
const card = elements.create('card')
card.mount('card-element');
}
}
Stripe: JavaScript SDK documentation & reference
See the LICENSE file for license rights and limitations (MIT).