S
SolidJS•11mo ago
ChrisThornham

Stripe Error: "ReferenceError: require is not defined"

I'm trying to add Stripe to a SolidStart project. In the Stripe docs, they ask you to initialize Stripe on the server with:
const stripe = require("stripe")('secret_key');
const stripe = require("stripe")('secret_key');
But require() doesn't work in SolidStart. You have to use import. After talking with Stripe, they said they didn't have an ES6 equivalent for initializing Stripe on the server. So... 1. How can I get around this problem? 2. Are there any good examples of how to get Stripe working in SolidStart?
2 Replies
Brendonovich
Brendonovich•11mo ago
can you not do this?
import Stripe from 'stripe';
const stripe = new Stripe('sk_test_...');
import Stripe from 'stripe';
const stripe = new Stripe('sk_test_...');
stripe does have esm exports
ChrisThornham
ChrisThornhamOP•11mo ago
@Brendonovich Thanks! Apparently, you should work for stripe support. 🤣 I'll dig into this later today. Have a good one. @Brendonovich it worked. Thank you.
Want results from more Discord servers?
Add your server