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
Gabriel
GabrielOP•17mo 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•17mo 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
Gabriel
GabrielOP•17mo 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•17mo ago
Oh yea that'd be fine gSSP and stuff doesn't care where you get data from
Gabriel
GabrielOP•17mo ago
Humm. I see. But is there a better way to do things?
Brendonovich
Brendonovich•17mo ago
I mean I wouldn't recommend using gSSP but if you're going to then that will work
Gabriel
GabrielOP•17mo 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•17mo ago
Yeah that sounds fine
Gabriel
GabrielOP•17mo 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•17mo 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
Gabriel
GabrielOP•17mo 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•17mo 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
Gabriel
GabrielOP•17mo 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