Can you help me figure out why this page is loading so fast?

https://nextjs-typescript-react-stripe-js.vercel.app/donate-with-elements I implemented Stripe Elements into my webpage yesterday. To load it you need to first create a payment intent and receive a secret client key to load the Stripe component. When you go on this site, the component just loads instantly as if the page is static or something...? You can see the GitHub repo below. I'm only concerned about the /donate-with-elements part. I've been trying to scour the code and see what they did differently, but I can't figure out how their page loads so fast.
TypeScript Next.js Stripe Example
Full-stack TypeScript example using Next.js, react-stripe-js, and stripe-node.
18 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
amanuel
amanuelOP2y ago
There is. For the PaymentElement component to render it needs a payment_intent which is fetched here:
useEffect(() => {
fetchPostJSON('/api/payment_intents', {
amount: Math.round(config.MAX_AMOUNT / config.AMOUNT_STEP),
}).then((data) => {
setPaymentIntent(data)
})
}, [setPaymentIntent])
useEffect(() => {
fetchPostJSON('/api/payment_intents', {
amount: Math.round(config.MAX_AMOUNT / config.AMOUNT_STEP),
}).then((data) => {
setPaymentIntent(data)
})
}, [setPaymentIntent])
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
amanuel
amanuelOP2y ago
And this API helper is awaiting
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
amanuel
amanuelOP2y ago
It is though
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
amanuel
amanuelOP2y ago
Yeah, so what the fuck? I tried it locally and ther it loads But on their website it doesn't load at all? How can you check this btw?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
amanuel
amanuelOP2y ago
I'd love to know how
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
amanuel
amanuelOP2y ago
It definitely does not run per request That's impossible
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
amanuel
amanuelOP2y ago
So it's non-functional practically then, right? Yeah It loads when I run it locally Even the stripe checkout itself is not that fast
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
amanuel
amanuelOP2y ago
Ok I'll try when I get on my computer Thanks for your insight I really appreciate it But the conclusion here is that this speed is non-functional
Want results from more Discord servers?
Add your server