Skip to content

Commit

Permalink
chore: resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
giraud florent committed Aug 6, 2023
2 parents e68ff2a + c5fae04 commit 206fef3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,19 @@ export default defineEventHandler(async (event) => {
### Client-side usage

On the client-side, you can use the `useClientStripe` function to get a Stripe instance.
This instance can be used in pages or plugins. This will be null on server side.

Use stripe inside pages or plugins
This composable is a wrap around the [`loadStripe`](https://github.com/stripe/stripe-js#loadstripe) and can be used in pages or plugins.

#### Example
```vue
<template>
<h1>Nuxt Stripe instance</h1>
<div>
{{ stripe }}
{{ stripe ? stripe : 'Loading...'}}
</div>
</template>
<script setup lang="ts">
// Import the function in your component or page
import { useClientStripe } from '@unlok-co/nuxt-stripe'
// Call the function to get the Stripe instance
// Call the composable to get the Stripe instance
const stripe = await useClientStripe()
// Use the Stripe instance to interact with the stripe.js library
Expand Down Expand Up @@ -114,6 +109,8 @@ export default defineNuxtConfig({
})
```

For all available `serverConfig` options take a look at the [official repo README](https://github.com/stripe/stripe-node#configuration). While for the `clientConfig` options take a look at the [official docs](https://stripe.com/docs/js/initializing#init_stripe_js-options).

> We highly recommend you put your **production** keys in your `.env` file to avoid committing them
## Development
Expand Down
5 changes: 1 addition & 4 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineNuxtModule, addPlugin, createResolver } from '@nuxt/kit'
import { defineNuxtModule, createResolver } from '@nuxt/kit'
import { StripeConstructorOptions } from '@stripe/stripe-js/types/stripe-js'
import defu from 'defu'
import Stripe from 'stripe'
Expand Down Expand Up @@ -52,9 +52,6 @@ export default defineNuxtModule<ModuleOptions>({
const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url))
nuxt.options.build.transpile.push(runtimeDir)

// Add runtime plugins
addPlugin(resolve(runtimeDir, 'plugins', 'stripe.client'))

nuxt.hook('imports:dirs', (dirs) => {
dirs.push(resolve(runtimeDir, 'composables'))
})
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/composables/useClientStripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Stripe } from '@stripe/stripe-js'
*
* This function is a helper to easily access the Stripe instance provided by the Nuxt plugin.
* It can be used in components or pages to interact with the Stripe.js library.
*
*
*/
export default async function useClientStripe() {
const nuxtApp = useNuxtApp()
Expand Down

0 comments on commit 206fef3

Please sign in to comment.