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
Neto
Neto11mo ago
nextauth manages the auth flow for you, specially stuff like oauth that is annoying to setup
Neto
Neto11mo ago
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/adapters
Adapters | 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.
.0sir1s
.0sir1s11mo ago
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?
Neto
Neto11mo ago
you would not make a api request to /api/example/hello the trpc client takes care of that for you
.0sir1s
.0sir1s11mo ago
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
barry
barry11mo ago
You’re still making requests TRPC just abstracts it away in the client
.0sir1s
.0sir1s11mo ago
but its not like writing
const res = await fetch('http://localhost:3000/api') {
method: 'POST',
// bla bla bla
}
const res = await fetch('http://localhost:3000/api') {
method: 'POST',
// bla bla bla
}
barry
barry11mo ago
Nope You should really just check out tRPC documentation
.0sir1s
.0sir1s11mo ago
so its just replacing that pretty much?
barry
barry11mo ago
Nope That’s way too dumbed down for me to be able to say yes
.0sir1s
.0sir1s11mo ago
okay, well how would you explain it?
Neto
Neto11mo ago
barry
barry11mo ago
I wouldn’t I would point you to the documentation
.0sir1s
.0sir1s11mo ago
alright i'll go have a read
Neto
Neto11mo ago
barry
barry11mo ago
I mean technically this is wrong in so many ways but sure theoretically
Neto
Neto11mo ago
for the correct theory -> trpc docs just a massive²³ oversimplification of what is going on
.0sir1s
.0sir1s11mo ago
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?
barry
barry11mo ago
What docs are you looking at
.0sir1s
.0sir1s11mo ago
Concepts | tRPC
What is RPC? What mindset should I adopt?
.0sir1s
.0sir1s11mo ago
barry
barry11mo ago
Oh yeah sure thought you were going into gRPC or something else
.0sir1s
.0sir1s11mo ago
lol
barry
barry11mo ago
You define typesafe functions on the backend which can be remotely called on the frontend Sums it up
.0sir1s
.0sir1s11mo ago
okay I think i've got a basic understanding for it now thanks for taking the time to explain it 😄
Vincent Udén
Vincent Udén11mo ago
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.