[app router] How to make sure secrets are not leaked to client
Unanswered
Cape lion posted this in #help-forum
Original message was deleted.
2 Replies
Holland Lop
There are a few options here. API routes, more commonly referred to as route handlers, are a great option, but can be rather slow.
A better alternative would be some combination of server components and server actions.
- I would recommend first looking into server components [here](https://nextjs.org/docs/app/building-your-application/rendering/server-components). Everything that happens in server components should stay on the server. You just have to be aware of the differences and use cases of server and client components (e.g. server components can't have state or hooks, etc.)
- As a less universal option, you could also look into server actions. These usually occur when a form is submitted, or a button is pressed. I like to think of them as streamlined API routes for when a user does something. Check those out [here](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations).
A better alternative would be some combination of server components and server actions.
- I would recommend first looking into server components [here](https://nextjs.org/docs/app/building-your-application/rendering/server-components). Everything that happens in server components should stay on the server. You just have to be aware of the differences and use cases of server and client components (e.g. server components can't have state or hooks, etc.)
- As a less universal option, you could also look into server actions. These usually occur when a form is submitted, or a button is pressed. I like to think of them as streamlined API routes for when a user does something. Check those out [here](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations).
Sorry, I misread your message haha... about the issue in particular you were having, could you send that code?