Next.js vs Laravel: performance comparison
When it comes to building web applications, developers often have to choose between different technologies. Two popular options for building web applications are Next.js and Laravel. In this article, we will compare the performance of Next.js (non-dynamic) and Laravel to help you decide which one is the best option for your project.
Next.js
Next.js is a popular framework for building React applications. It provides server-side rendering out of the box, which can help improve the performance of your web application. However, Next.js also supports non-dynamic rendering, which means that it can pre-render your pages at build time, resulting in faster loading times for your users.
Laravel
Laravel is a PHP framework that is known for its easy-to-use syntax and powerful features. It provides tools for building web applications, including server-side rendering. However, compared to Next.js, Laravel may require additional configuration and optimization to achieve optimal performance.
Performance Comparison
When it comes to performance, Next.js (non-dynamic) has the advantage of pre-rendering pages at build time, resulting in faster loading times for users. This can be especially beneficial for web applications with a lot of static content, such as landing pages or marketing websites.
Laravel, on the other hand, may require additional steps to achieve optimal performance, such as caching and server-side optimization. While it is possible to achieve good performance with Laravel, it may require more effort compared to Next.js (non-dynamic).
Conclusion
In conclusion, when it comes to performance, Next.js (non-dynamic) has the advantage over Laravel. Its ability to pre-render pages at build time can result in faster loading times for users, especially for web applications with a lot of static content.
However, it is important to note that the choice between Next.js and Laravel should not solely be based on performance. Consider other factors such as your team’s expertise, project requirements, and scalability before making a decision on which technology to use for your web application.
I discovered that Next.js wasn't reflecting database changes, making this comparison unfair. Here an update version: https://youtu.be/2-SVojp_BVc
Sorry JS Devs.
Add Django Python in comparison.
p.s. nice video.
Performance is not a problem in small-mid size apps, which are about 90% of all the applications on the internet. The speed of development and the developer experience are the essential factors here.
When performance is the most important neither PHP nor JS are good choices, you can go with GO, C#, JAVA pretty much any compiled language
Man your next JS doesn't request anything from db as laravel does, there is no language that can perform db request and response in under 100ms, not even on specialized embedded RT, please check the process of both to see what are they doing cause something is not right here
Can you test it with rails as well??
I don’t know guys why you so scared of Laravel 😂. Literally js devs are so worried their stuff is better than any others 😅 it is just funny to watch. Laravel community is just happy, customers are happy. You should try it.
To get a fair comparison, it has to be someone that uses both frameworks. For example I saw someone suggest that MillionJS would be a plus for NextJS but MillionJS is not limited to NextJS and can also be use with Laravel and InertiaJS.
Just a point to note, there is an existing package called InertiaJS which basically allow Laravel to do most of what Sveltekit, NextJS and NuxtJS does. I can build a Laravel app using Svelte, React or Vue with seamless data fetching and form submission without the need for any endpoint.
With Inertia, they already had persistent layout which is just introduce in NextJS 13. Not to mention it included shared props where you can access the server props from any components unlike NextJS. Inertia also include form submission without the need to call an endpoint which is just being introduced in NextJS.
I uses both frameworks because NextJS have a few advantages in itself like Prefetching and is better supported than InertiaJS but I believe to compare you have to understand both tools to make a fair assessment.
If that wasn’t enough, they have there own framework called Livewire that was built and maintain by the creator of AlpineJS. The package offer similar features such as NextJS for persons that don’t want to use a JS framework. Hence why I mention in one of my replies that Laravel is a beast. Livewire offer SPA, prefetching and reactivity just to make it clear.
For performance comparison you can check online for PHP swoole vs NodeJS.
If you compare them based on speed, Laravel is pretty lacking. I would suggest giving Trongate a try, as it was built specifically for speed.
I know this would trigger Laravel developers, this is just normal NextJS SSR without MilionJS. 😁
Fortunetly, performance is not the criteria for every aplication.
But is a good start.
Up to a few thousands users is not something to worry. If it is not to scale more than that, you can use wathever is more confortable. And Laravel is pretty good to develop, still didn't try next.js, but Laravel is worth the fame it has.
The video is a good idea, but unfortunately the test design is apples and oranges. Next.js keeps the app in memory while Laravel (by default) spins up the framework from scratch on every request. Instead of running Laravel in its default mode, I'd suggest you enable Octane mode – in which Laravel will keep the app in-memory between requests – to achieve a more fair representation of performance.
The comparison between these two frameworks was not right from the start