T
TanStack11mo ago
adverse-sapphire

Start - When to use Api routes and server functions

I'm learning tankstack start and i'm not sure about why and when to use API routes, isn't server functions better, since it provides typescript end-to-end support and only executes on the server? Why shouldn't i only use server functions?
3 Replies
like-gold
like-gold11mo ago
if you want to create external API endpoints for other apps to use, use API routes
adverse-sapphire
adverse-sapphireOP11mo ago
so for a normal application where there are no external communication, the best is to only use server functions?
deep-jade
deep-jade11mo ago
correct. there's no need to manually expose an endpoint for your app to use since start does this under the hood for the client and server to communicate when using server functions

Did you find this page helpful?