short question
Unanswered
Southeastern blueberry bee posted this in #help-forum
Southeastern blueberry beeOP
was nextjs designed to be a backend-for-frontend or to stand on its own? hope@American black bear or @Satin Angora can respond me thank you 

68 Replies
Assuming they are not able to respond (they must be mega busy and perhaps they don't check the discord at all 🤯 )
To answer your question, Next.js is a full stack framework built on top of React.js.
Not sure what did you mean by "backend-for-frontend" 🤔
https://nextjs.org/docs#what-is-nextjs
To answer your question, Next.js is a full stack framework built on top of React.js.
Not sure what did you mean by "backend-for-frontend" 🤔
https://nextjs.org/docs#what-is-nextjs
@James4u Assuming they are not able to respond (they must be mega busy and perhaps they don't check the discord at all 🤯 )
To answer your question, Next.js is a full stack framework built on top of React.js.
Not sure what did you mean by "backend-for-frontend" 🤔
https://nextjs.org/docs#what-is-nextjs
Southeastern blueberry beeOP
hey, it's a fairly common pattern in software architecture (https://learn.microsoft.com/en-us/azure/architecture/patterns/backends-for-frontends), especially for microservices. I'm asking because next seems to be super well adapted to this pattern and I'm curious to know if it's intentional or not
@Southeastern blueberry bee Pattern is about having different backend services for desktop and mobile
I wonder how it's related to the Next.js framework
Southeastern blueberry beeOP
Let's say you have an application written in golang, it takes care of system-level manipulations (go is superbly suited to this kind of thing). And you need a user interface, you decide to design it with nextjs, but you realize that you won't be using many of the apis offered by nextjs, such as server actions or route handlers, since your frontend will call your go api directly.
this is where the backend-for-frontend concept can help
you can do aggregation, benefit from nextjs caching, server action... From this bff
first of all, if I understood correctly, backend-for-frontend is about having different backend services for desktop vs mobile, no?
Southeastern blueberry beeOP
yes one of other benefit
like network latency, since aggregation is done on the bff...
better separation of concern
hidde api keys, in brief lot of good thing
I'm going to write an article about it to get the concept into my head, and if it helps others... (look at ma bio)
okay then let say, we use Next.js to build website - we may want to use different backend for desktop vs mobile?
so having different services (that can be also written in different languages) and use next.js api as proxy?
Southeastern blueberry beeOP
thats it !
oh yeah I see, I should have understood earlier
@James4u okay then let say, we use Next.js to build website - we may want to use different backend for desktop vs mobile?
but I think this is only a possible assumption
I think the real world example can be website for the desktop devices and mobile app for mobile devices
you know for the same product, mobile app has different UI and has limited features (sometimes)
I guess
backend-for-frontend meant it - I might be wrongin this case, Next.js can NOT be on the topic
Southeastern blueberry beeOP
can i know why please
it's because they mostly use different lanuage/framework for building mobile app
let say they build web using Next.js
and they build mobile app using Flutter
they will have different backend services for web and mobile
Southeastern blueberry beeOP
its not about mobile only
@James4u they will have different backend services for web and mobile
Southeastern blueberry beeOP
yes
next is for web only
@Southeastern blueberry bee yes
then Next.js api routes will be only for web
Southeastern blueberry beeOP
yes nextjs = backenf for frontend of web front
you can also have another backenf for frontend but related to mobile views
then what if we use just React instead of Next.js for web?
and use Flutter for mobile
Southeastern blueberry beeOP
so whats backend for frontend we use for react ?
anything
Southeastern blueberry beeOP
yes of course you can
my bad is in french
hmm I dunno French
so my main question is
Southeastern blueberry beeOP
translate it well worth a read
@James4u so my main question is
Southeastern blueberry beeOP
yep
(as you said Next.js is designed to be a backend-for-frontend)
Southeastern blueberry beeOP
no its a question haha
dunno forgot to how to explain/ask
okay so how Next.js is good as "backend-for-frontend" in other words having differnet services for mobile vs desktop?
if it's only used for the web (in our previous story)
if it's only used for the web (in our previous story)
Southeastern blueberry beeOP
"how Next.js is good as "backend-for-frontend" => offer caching, performance, and security
@Southeastern blueberry bee "how Next.js is good as "backend-for-frontend" => offer caching, performance, and security
ofc I know - it's just Next.js features
but as far as I understood it's about setting up itermediary api layer that communicates to 3rd parties
still am not sure because from my understanding BFF is
- a design pattern of having different backend services for desktop vs mobile
- an intermediary api layer that moves all connection management with services out of the frontend
- a design pattern of having different backend services for desktop vs mobile
- an intermediary api layer that moves all connection management with services out of the frontend
so my doubt about your thoughts (Next.js is designed for BFF)
I agree on the second point, but on the first point if Next.js is only used for the web it doesn't make sense
I agree on the second point, but on the first point if Next.js is only used for the web it doesn't make sense
Southeastern blueberry beeOP
i can also create bff for mobile
since my backend is made in go
nextjs will just act as a bff
then aother next.js for bff for mobile?
or one next.js bff for web and mobile?
Southeastern blueberry beeOP
think of the first bff as nextjs bff and the second one a flutter bff and the api is the core app
you can also add smartwatch bff for connected watch software
Its all up to how you want to do it... nextjs can do anything another backend can do. I would only wander over to another library if there was a ton of traffic expected and even then nextjs can likely handle it.
Korat
I use NextJs heavily as BFF since the backends are written in .NET
@Korat I use NextJs heavily as BFF since the backends are written in .NET
Southeastern blueberry beeOP
Have you noticed any benefits compared to using ReactJS directly? React <=> .NET
Korat
As mentioned above, you can aggregate or prefetch multiple data in server components before javascript loads.
- Overall, the apps feel really fast in my opinion.
- Being able to hide the original api from network is also a benefit.
- You can generate pdfs using route handlers so .Net developers don't have to worry about design xd.
- Storing the auth tokens in server side cookies feels safer.
A downside is the developer experience, sometimes you are tempted to validate the data in server actions even though it's not necessary and it just feels like you are overengineering all the stuff.
- Overall, the apps feel really fast in my opinion.
- Being able to hide the original api from network is also a benefit.
- You can generate pdfs using route handlers so .Net developers don't have to worry about design xd.
- Storing the auth tokens in server side cookies feels safer.
A downside is the developer experience, sometimes you are tempted to validate the data in server actions even though it's not necessary and it just feels like you are overengineering all the stuff.
Southeastern blueberry beeOP
Thank you for the feedback
Korat
@Southeastern blueberry bee every metaframework can be used as BFF, remix has a section for just this https://remix.run/docs/hi/main/guides/bff