#MATTI
1 messages · Page 1 of 1 (latest)
Hi there!
I'm not familiar with Next.js, but I'll try to help.
Are you writing frontend code or backend code?
NextJS is a framework on top of react, that allows the ability to write code that only runs on the serverside, inside the getServerSideProps function, you can then send the variables you need back to the browser. So this code is running on the server.
Currently i am using it to get a list of invoices, and sending them to the browser.
And is it working?
Yea, everything is working fine.
Since i am currently only fetching the data, i can just run that inside the getServerSideProps function. But this function only runs whenever i load the page, so i can't use that function to create new data for example. So i need to get access to the stripe object outside that function.
I have no clue if what i said makes sense.
If you just want to re-use the Stripe instance then just export it from a lib file or something that you can import elsewhere
Like this, for example: https://github.com/vercel/nextjs-subscription-payments/blob/main/utils/stripe.ts
But wouldn't that expose the secret key?
Why would it? It only runs server-side
Hola, cordial saludo, vendo de parte de kick, me dice que debo cambiar mi direccion IP para solucionar un bloqueo que tengo en la cuenta, podrias ayudarme a hacer esto? gracias.
Vengo*
Let's say i use the instance to create a new customer after typing in some inputs and pressing a button, wouldn't that expose the secret key?
Well yeah you wouldn't use it in a client component. What you'd do in that scenario is have an API Route/Route Handler that your form POSTs data to and then you use the Stripe lib there to create the Customer
Hello, best regards, I come from kick, tells me that I must change my IP address to solve a block I have on the account, could you help me do this? Thank you.
Aright, that makes sense. Thank you!
All of this is simpler with the App Router in Next.js 13 (and React Server Components)
Yeah, just saying