#MATTI

1 messages · Page 1 of 1 (latest)

near gullBOT
steady summit
#

Hi there!

#

I'm not familiar with Next.js, but I'll try to help.
Are you writing frontend code or backend code?

woven tendon
#

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.

steady summit
#

And is it working?

woven tendon
#

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.

soft tartan
#

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

woven tendon
#

But wouldn't that expose the secret key?

soft tartan
#

Why would it? It only runs server-side

mild quartz
#

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*

soft tartan
woven tendon
#

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?

soft tartan
#

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

mild quartz
#

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.

soft tartan
woven tendon
soft tartan
#

All of this is simpler with the App Router in Next.js 13 (and React Server Components)

woven tendon
#

I am not currently on nextjs 13

#

I will figure it out.

#

Thank you.

soft tartan
#

Yeah, just saying