Can I still get features like SSR/ISR with this infrastructure?

Hi everyone, I need to understand a bit about SSR/ISR with this infrastructure I have built. I was first wanting to understand security implications to scaling multiple apps for my frontend, serving the HTML/JS to the users, while they consume my master backend, with all of the business logic
13 Replies
GBianchi
GBianchi•11mo ago
I was wondering, can I still get features like SSR/ISR if in the client applications (E.g. App1 or App2 in the picture) fetch the data from my Master backend while still in the server? Is there a better way t structure this?
Brendonovich
Brendonovich•11mo ago
SSR would be fine, ISR just depends on how you deploy. Looks like you'll be deploying everything on Vercel so that should all work. You'd only benefit from those if you're actually fetching while server rendering though, from the looks of things your client would be doing fetching separately
GBianchi
GBianchi•11mo ago
For example, in my App1 I could have
getServerSideProps(){
const data = await fetch(myBackendHereURL)
return {
props: {
data,
},
}
}
getServerSideProps(){
const data = await fetch(myBackendHereURL)
return {
props: {
data,
},
}
}
Brendonovich
Brendonovich•11mo ago
Oh yea that'd be fine gSSP and stuff doesn't care where you get data from
GBianchi
GBianchi•11mo ago
Humm. I see. But is there a better way to do things?
Brendonovich
Brendonovich•11mo ago
I mean I wouldn't recommend using gSSP but if you're going to then that will work
GBianchi
GBianchi•11mo ago
I am trying to structure one big backend that I can access from dfferent frontends. I basically have it structured already so that the clients (computers in the image) can access the master backend with trpc. Working fine
Brendonovich
Brendonovich•11mo ago
Yeah that sounds fine
GBianchi
GBianchi•11mo ago
Okay. Cool! And @brendonovich, do you know if I can call my Master backend from my Apps using trpc? (Serverless function calling another serverless function using trpc)
Brendonovich
Brendonovich•11mo ago
Technically yeah, it's all just fetch requests between servers. I'm not sure on the specifics of how you'd setup the tRPC clients
GBianchi
GBianchi•11mo ago
So, instead of that I would have something like
getServerSideProps(){
const data = trpc.posts.getAll.useQuery()
return {
props: {
data,
},
}
}
getServerSideProps(){
const data = trpc.posts.getAll.useQuery()
return {
props: {
data,
},
}
}
I mean, I think useQuery is a hook for react, so But I'm guessing it can work. That's good to know.
Brendonovich
Brendonovich•11mo ago
It might just be as simple as initializing a vanilla client on the server https://trpc.io/docs/client/vanilla/setup Actually since you're server-rendering you might need the SSR helpers https://trpc.io/docs/client/nextjs/server-side-helpers
GBianchi
GBianchi•11mo ago
I see Thank you. I'll look into it later For now I'm setting it all up so that I can have Auth working as well 😄
Want results from more Discord servers?
Add your server
More Posts
Implementing next auth adapter with a cacheso I've implemented an adapter for next auth which would try to cache certain things in memory via tMade a small CSS styled componentI know it's not the biggest thing but I got some feedback about my naming in a question before and IVercel Deployment giving prerender errorI am getting this error when I deploy on vercel but its running locally.@acme/nextjs:build: Error ocFeedback for my infrastructure needed!I'm trying to understand best practices for creating one infrastructure for my startup. Would like sUtility type to "undiscriminate" a discriminated unionSo this might be kind of a hacky thing, but I've got a use case that could greatly benefit from it. Generated types from Prisma client are not getting assigned automatically.I'm currently following the create-T3-app tutorial with some small twists on my end (I use NextAuth For whom and when does it make sense to learn a Framework like React.I am relatively new to webdev and currently just use Flask for my backend to render my HTML files anClerk | Next 13: 401, unauthorized when trying to hit Next backend.I have set up the following middleware: ```ts import { authMiddleware } from "@clerk/nextjs"; exportCreating (guest)checkout sessions with TRPC/Stripe/Zustand.Hi! Just asking to see if this is a correct approach I am managing carts using Zustand since it is Best sources for UI inspiration?I know there are some websites where devs can show off their UI and you can gather inspiration, but