Use react cache() in proxy.ts?

Is there a way to use the built-in React cache() function to set a cached value in proxy.ts and then use that value in actual server components now that Next 16 moves Proxies to run in the Node runtime?

On dev I’m setting a value this way but I don’t see it reflected in the server components.

The reason I want to do this is for paraglide JS, an i18n library - right now since passing values via headers or cookies requires accessing them as Promises, and server component renders happen in parallel, even if you set the active locale that the library uses from the header in your root layout, that value will not be made present to other rendered components before they get rendered on the server. So running such code in proxy.ts seems like a good idea since that should run before the actual component renders; and React cache() would be an ideal way to set it per-request without the need for awaiting Promises; but that doesn’t seem to work.

Relevant discussion: AsyncLocalStorage From middleware to server component · vercel/next.js · Discussion #76582 · GitHub

This is not possible, the proxy.ts runs often on a different server entirely than the rest of the app, so there is no way to pass data between them

This is one of the reasons that middleware.ts was renamed to proxy.ts, to clear up misconceptions that it worked like Express Middleware

So if you need to get the locale for the user and share it between your components it needs to happen in your app code

@omar-breeze, just checking in on your question about using the React cache() function in proxy.ts. Have you found a solution or still need assistance with sharing data in your server components? Let me know if that helps!