Next.js Discord

Discord Forum

Laravel vs Next.js: Scalability and Backend Separation in Full-Stack Development

Unanswered
Exotic Shorthair posted this in #help-forum
Open in Discord
Exotic ShorthairOP
I'm evaluating Laravel and Next.js for a new project, focusing on future scalability. Here's my understanding and concern:
With Laravel:

I start with a full-stack Laravel app (backend + frontend).
When I hit scaling limits, I can keep the Laravel backend intact.
I can then create a new, separate frontend on another server.
The existing Laravel backend can serve this new frontend via APIs.
I don't need to rewrite my backend logic, just develop the new frontend.

With Next.js:

I start with a full-stack Next.js app.
If I hit scaling limits and need to separate concerns, I'm unsure of the process.
Can I keep Next.js as just the backend and create a new frontend?
If not, do I need to extract and rewrite the backend logic separately?

Given Next.js is considered full-stack with Server Actions and API Routes, how does it handle this scaling scenario? Can it serve multiple frontends like Laravel can? Are there architectural patterns in Next.js that allow for easy separation of frontend and backend as the app grows?
I'm trying to understand the trade-offs in scalability and architecture between these two approaches. How does Next.js' scaling strategy differ from Laravel's, and what should I consider when choosing between them for a potentially large-scale application?

If you know someone who can consult me on that I will be more than happy. I really want to uderstand these thigns. To choose where to invest in.

8 Replies

@Exotic Shorthair I'm evaluating Laravel and Next.js for a new project, focusing on future scalability. Here's my understanding and concern: With Laravel: I start with a full-stack Laravel app (backend + frontend). When I hit scaling limits, I can keep the Laravel backend intact. I can then create a new, separate frontend on another server. The existing Laravel backend can serve this new frontend via APIs. I don't need to rewrite my backend logic, just develop the new frontend. With Next.js: I start with a full-stack Next.js app. If I hit scaling limits and need to separate concerns, I'm unsure of the process. Can I keep Next.js as just the backend and create a new frontend? If not, do I need to extract and rewrite the backend logic separately? Given Next.js is considered full-stack with Server Actions and API Routes, how does it handle this scaling scenario? Can it serve multiple frontends like Laravel can? Are there architectural patterns in Next.js that allow for easy separation of frontend and backend as the app grows? I'm trying to understand the trade-offs in scalability and architecture between these two approaches. How does Next.js' scaling strategy differ from Laravel's, and what should I consider when choosing between them for a potentially large-scale application? If you know someone who can consult me on that I will be more than happy. I really want to uderstand these thigns. To choose where to invest in.
If you deploy to serverless platforms like vercel, The App Can horizontally scale
you can use nextjs as a frontend, However, I wouldn't recommend it. Its better to use express or fastify
American Chinchilla
@"use php" but isnt express single thread?
I actually meant deploying it to serverless platform
Exotic ShorthairOP
Let me put it this way:
Imagine you have an idea, and you're eager to start building it as soon as possible. You have two options: Laravel and its entire ecosystem, or Next.js. Both allow you to develop your MVP quickly, though Laravel might be slightly faster since you don’t have to choose from a vast array of services—Laravel's ecosystem is fully supported by its own team.
Now, let’s say your hypothesis is validated, and your project begins to scale, along with your development team. If you chose Laravel, you could easily use what you've already built as your backend and introduce a new frontend, perhaps with React or Vue (whether in JavaScript or TypeScript).
But what if you chose Next.js? How would you handle the same scenario? Would you need to make any significant changes? What if server actions become the new standard, eliminating the traditional separation between backend and frontend? What if you could split a Next.js project into distinct server and client components?
In the Laravel scenario, introducing a frontend later is straightforward. However, if I chose Next.js, I might eventually need to introduce a backend. To me, introducing a backend feels more risky and complex than introducing a frontend.
I apologize if this sounds confusing or frustrating. I'm genuinely trying to understand and learn more about these concepts.
But what if you chose Next.js? How would you handle the same scenario? Would you need to make any significant changes? What if server actions become the new standard, eliminating the traditional separation between backend and frontend? What if you could split a Next.js project into distinct server and client components?

If you choose to host nextjs in a serverless platform like vercel or cf pages, It'll horizontally Scale.
You can also just use nextjs for the frontend, And get the data from backend OR create a new backend in nextjs.
Exotic ShorthairOP
This is exactly what I try to understand. What do you mean by "create a new backend in nextjs". How that works?
@Exotic Shorthair This is exactly what I try to understand. What do you mean by "create a new backend in nextjs". How that works?
I mean, Once you create a frontend in nextjs, you can also use it to build a backend, like by using server actions or route handlers