Understanding the t3-stack
so i'm just trying to understand the t3-stack better before I do more building with it (specifically the backend).. just want some clarification/corrections on my understanding so far
nextauth - sessions/authentication for the app which can either be OAuth or email
trpc - just an api kind of thing to semi-replace pages/api in nextjs that connects frontend to backend better?
26 Replies
nextauth manages the auth flow for you, specially stuff like oauth that is annoying to setup
trpc makes typesafe calls between systems
the
/api
aspect of trpc/next is to host your api with nextjs itself
you can use trpc with other kinda of apis, such as: https://trpc.io/docs/server/adaptersAdapters | tRPC
tRPC is not a server on its own, and must therefore be served using other hosts, such as a simple Node.js HTTP Server, Express, or even Next.js. Most tRPC features are the same no matter which backend you choose. Adapters act as the glue between the host system and your tRPC API.
so with the example code from create-t3-app
instead of doing a request to localhost:3000/api/example/hello
you can instead just do something like
api.example.hello
am i getting that right?
you would not make a api request to /api/example/hello
the trpc client takes care of that for you
okay so just instead of having to build the api shit inside pages/api/
I can just go into server/api and build my functions there for use in the frontend, substituting the need for making api requests
You’re still making requests
TRPC just abstracts it away in the client
but its not like writing
Nope
You should really just check out tRPC documentation
so its just replacing that pretty much?
Nope
That’s way too dumbed down for me to be able to say yes
okay, well how would you explain it?
I wouldn’t I would point you to the documentation
alright i'll go have a read
I mean technically this is wrong in so many ways but sure theoretically
for the correct theory
-> trpc docs
just a massive²³ oversimplification of what is going on
With traditional HTTP/REST APIs, you call a URL and get a response. With RPC, you call a function and get a response.does that basically cover it?
What docs are you looking at
Concepts | tRPC
What is RPC? What mindset should I adopt?
Oh yeah sure thought you were going into gRPC or something else
lol
You define typesafe functions on the backend which can be remotely called on the frontend
Sums it up
okay
I think i've got a basic understanding for it now
thanks for taking the time to explain it 😄
Don't ask this in a thread about something entirely different. Post a new question. Provide error messages. This question doesn't give other people anything to go on.