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
Neto2y ago
nextauth manages the auth flow for you, specially stuff like oauth that is annoying to setup
Neto
Neto2y 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
0sir1sOP2y 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
Neto2y ago
you would not make a api request to /api/example/hello the trpc client takes care of that for you
0sir1s
0sir1sOP2y 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
barry2y ago
You’re still making requests TRPC just abstracts it away in the client
0sir1s
0sir1sOP2y 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
barry2y ago
Nope You should really just check out tRPC documentation
0sir1s
0sir1sOP2y ago
so its just replacing that pretty much?
barry
barry2y ago
Nope That’s way too dumbed down for me to be able to say yes
0sir1s
0sir1sOP2y ago
okay, well how would you explain it?
Neto
Neto2y ago
barry
barry2y ago
I wouldn’t I would point you to the documentation
0sir1s
0sir1sOP2y ago
alright i'll go have a read
Neto
Neto2y ago
barry
barry2y ago
I mean technically this is wrong in so many ways but sure theoretically
Neto
Neto2y ago
for the correct theory -> trpc docs just a massive²³ oversimplification of what is going on
0sir1s
0sir1sOP2y 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
barry2y ago
What docs are you looking at
0sir1s
0sir1sOP2y ago
Concepts | tRPC
What is RPC? What mindset should I adopt?
0sir1s
0sir1sOP2y ago
barry
barry2y ago
Oh yeah sure thought you were going into gRPC or something else
0sir1s
0sir1sOP2y ago
lol
barry
barry2y ago
You define typesafe functions on the backend which can be remotely called on the frontend Sums it up
0sir1s
0sir1sOP2y 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én2y 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.
Want results from more Discord servers?
Add your server