#[app router] How to make sure secrets are not leaked to client

2 messages · Page 1 of 1 (latest)

nova heraldBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

dreamy oyster
#

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. 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.