How to call a server function without tRPC?
Hi! I'm kinda noob on the T3 stack. I created a t3-app without nextAuth and tRPC. However, the scaffolded code doesn't cover a use of the server side code and I wasn't able to figure out how to do it. I tried to export a variable from the server directory, but I got the following error in the app page:
Error: ❌ Attempted to access a server-side environment variable on the client
2 Replies
I think you need to dive into next js docs and understand where the client and server live in code
You don't call a server function from the client without an API call
You can write a function and import it to both the client and server but then it has to not use anything client or server specific (no dom stuff, no node apis)
look at how the
hello
query in the scaffolded index.tsx
works