10
b2plane
280d

How is coupling backend + frontend as a single nextjs app a good idea? What the fuck is this?

What if you have to create new replica sets of a backend because of high load pressure? What about load balancers?? What if i want my backend to be a microservice? How do i unit test the backend if its cluttered with frontend? WTF IS THIS

WHY DID NEXTJS THINK THIS IS A GOOD IDEA AND WHY DO SO MANY DEVS LOVE THIS IDEA AND GLORIFY NEXTJS?

Nextjs seems like the type of framework that was built by a frontend web developer who just refuses to learn backend technology at all costs.

---

its been a few hours and the concept of nextjs is bending my mind rn. I thought nextjs is just another frontend framework. A react killer. Only to find out its both a backend + frontend framework.

Cluttering backend stuff into frontend is gonna get messy no matter how much you try to modularize the code. Am i lost or am i right???

---

Scratching my head over nextjs. Looks like a great framework for small-mid project but definitely not large project. The more shit the project needs the more messy shit become. Angular has modularized all of this in separate folders -- components services guards interceptors (now new stuff coming called Signals) etc. All of it is separated in individual folders and kept frontend-only. Simple enough. No backend clutter

---

Can i even use nextjs strictly as a frontend framework while it uses my custom backend built in java spring boot? For example use nextjs /api/ folder to handle custom routes built outside of nextjs framework?

Am i insane here

Comments
  • 5
    I can't speak for nextKS specifically, but you hit the nail on the head. Monoliths are great for small and medium sized projects.

    Gotta Keep It Simple Stupid, and go fast at all costs. Future scaling requirements be damned.

    I think there are good test frameworks in JS though. I'm not a JS guy though, so I'm not 100% on it.
  • 1
    @lungdart what are you trying to say? I should start with nextjs and if the project succeeds big and generates sales then i should hire experienced devs to develop a separate backend as microservice and scale horizontally?

    Right now I'm building separate backend which is a monolith. Ofc its not gonna be microservice. Its a prototype
  • 6
    * 18 months later *

    Business: we want it to be a mobile app as well. Exactly the same features but has to be an app users can download for Android AND IOS.
    Devs with coupled front-back end: oh shit

    ^I mean you might be alright if you always have big firegaps been the frontend and backend code in the repo around your APIs so new UIs are easier to slot in 🤷
  • 2
    @b2plane yeah that's basically the jist of it. Don't scale until you need to scale, because 90% you'll fail before that anyway, and you don't want a complex microservices system to be a reason for it.

    if right now you have a separate back end, you have a dualith, not a monolith. Not that there's anything wrong with that. I'm a big fan of separation between front and back ends, but when you have a small team and a smaller budget, you do whatever is fastest. And that's monoliths.
  • 3
    Write a script that will automatically insert use client at the beginning of every.tsx file 😂

    On a serious note, you should check vite script. You have something like CRA but with vite as bundler and yarn as pm
    And it uses the page router.

    It's so far the closest thing to what you're asking
  • 2
    @lungdart I think the problem with nextJS 13 is beyond monolith vs microservice question. The idea of writing a backend in js isn't very tempting for lot people. So imagine not only having to write the backend in J's, but also being forced to couple it with the front, same codebase. Kind
  • 1
    @MammaNeedHummus exactly. What happens then? How do i code a mobile app if the backend is built in nextjs?
  • 0
    @lungdart lets say the project im building is very similar to onlyfans website. So imagine how their system works. You have login registration. Chatting. Push notifications. Timeline of posts. Images videos and text posts. If users can chat in real time then i need ability to block each other. Mute notifications. Not to mention i need a stripe integration or some similar 3rd party payment provider that can process payments and generate sales? Yeah thats pretty much summed up

    What do you say now is nextjs as backend + frontend a good idea for this or should i stick to building backend in java spring boot (monolith) and angular?

    If i choose nextjs i can deploy it to vercel and job done. I dont care about unit testing nor do i know how to do it in a clusterfuck of nextjs. If i choose the latter id deploy it via aws elastic beanstalk, write unit tests and ci/cd.
  • 2
    @b2plane it's time for vue!
  • 2
    LoL. React is Next.js at this point. Also, you are expected to use next.js along with vercel infrastructure. Vercel will handle all scaling issues for you even though they suffer from outages often.

    You probably should watch some talks regarding meta frameworks before jumping in 😂. If you are gonna build an app that is locked behind authentication. Don't use nextjs
  • 1
    @b2plane you use all 3rd party services for those features. Abuse the heck out of s3, and ship something with RCE built in as a feature, and cash the VC cheques before they know the difference.
  • 0
    @lungdart im always trying to avoid 3rd party paid services as if my life depends on it
  • 1
    @b2plane because you're not optimizing for speed!

    In all seriousness, there are great open-source self hosted alternatives to saas, and all you have to do is not being afraid of hosting more than one thing.

    Personally, I run k8s clusters, and fire everything into them. Costs be damned! I even run k8s at home on my proxmox cluster.
  • 1
    Is there even any point in trying to explain? It's been three hours between your posts and you're already convinced NextJS and the idea of SSR is complete trash. All based on what seems to be practically no experience using it and a very close minded approach. Good job 👍
  • 0
    what is your stance? I prefer SSR, which is why things like Rails with no frontend in the form of a JS app, or PHP, or Python, or Go, or JS works for me. Are you in favour of SSR from a language?
  • 0
    @ScriptCoded @AleCx04 i have very mixed feelings about nextjs. I want to like it but its weird. I like ssr but not like this cluttered among frontend. The whole thing is fucking weird as shit bro. How would you build a mobile app as extension to the website if the backend is built in nextjs?
  • 0
    Every X years someone decides the next new thing is bundling frontend and backend in a single project.

    Exactly 6 months after that we are reminded why it's a retarded thing to do.
  • 0
    NextJS is a glorified Wordpress but with more restrictions since the “backend” can’t even read env vars, use fs modules, etc.

    Wait until you try to cache image loaders resources with your CDN …
  • 0
    FWIW, getting to the direct question:

    "Can i even use nextjs strictly as a frontend framework while it uses my custom backend built in java spring boot? For example use nextjs /api/ folder to handle custom routes built outside of nextjs framework?"

    Yes, absolutely you can. Or alternatively, you can compile the whole lot to static assets, host on a platform of your choice, and then just have your frontend call your SB backend directly (you'll just need to set up CORS correctly for this to work.)
  • 1
    NextJS is a market for Vercel and excuse for React. Good luck sleeping at night if you have to work with that. 😕
  • 0
    Also, I agree, this is ridiculous to couple entire frontends and backends with such a framework. It's running away from original REST and not adopting HATEOAS, which means backend has no future.
Add Comment