React with Next.js vs Ruby on Rails

React with Next.js vs Ruby on Rails

Mon Aug 24 2020 - by Kirill Zubovsky

As a long-time Ruby on Rails developer I was really hesitant to try something new. Learning is time consuming, it requires exploring and making mistakes. Why bother, if you already know a language that works pretty great, and gets the job done?

While Ruby is a lovely language, and Rails is a fantastic framework which enabled countless startups to launch and become famous, Rails also has limitations which can be easily overcome with React, and the time and cost savings are worth the initial learning curve.

React enables a smooth transition from a monolith app, where everything is programmed from one code base, to a component based app, where logic, data, and presentation are handled by multiple applications. It was developed out of necessity to run an efficient engineering operations with thousands of developers, but it scales equally well for a company of one.

With React you can easily split your application into parts where front and back are developed, maintained and deployed by different teams, at different times. This improves flexibility across the board. Different teams can work on a single app, but improve it in steps, without affecting each other.

React simply listens to new data and updates your application when the data is updated. It's magic!

Facebook, the React parent, did lots of pretty forward-thinking development, and Rails team has been playing catch up. Rails is still a great way to build logic bits for your application, to be the brain and the datacenter of your app, but as far as display of information is concerned, React is a few steps ahead.

Before Next.js, I was afraid of React. If something broke in Rails, I knew where to fix it, or at least how to look for the right information which would enable me to fix it. I was familiar with a bunch of useful gems, and the MVC model was well engrained in my head. Rails was familiar, and comfortable. The paradigm change from Rails to webpack/node/react ..etc, it seemed more work than I was willing to put in.

Next changed everything. They took everything that was good about React, sprinkled some useful simplifications, made it idiot-proof (thank you!), and put it all on efficient pipeline that deploys blazingly fast (seconds vs. minutes). Now that I have taken the time to understand it a little, I can launch a brand new website using Next in a matter of minutes, deploy it to Vercel in seconds, and show it to customers in that moment. Then, if I want to make a change, re-deployment only takes a few seconds. Quite literally, it took only 35 seconds to deploy this blog post.

If I were to pick my top 3 favorites about Next, it would be this. (1) It turns your entire website into a series of static pages that render really fast, for really cheap. Right now, hobby hosting on Vercel costs $0, and that's a pretty great price! (2) Next.js does not require a database to start, which removes the unnecessary complexity for both local dev and deploy. On top of that, when needed, the "database" can be literally anything, from Postgres to a Google Sheet, which again makes it simple and cheap. (3) It's made React Routing manageable, so when users click on a link, it works just like it would in a normal static html, with the underlying complexity hidden away. This might be a small thing by dev standards, but it's a huge plus when it comes for a particular purpose of lauching usable websites.

Learning gives you options, whether you are learning a new foreign language, or learning to use a fork, learning enables a new experience that leads to new, usually better outcomes. It is no different for programming, and I highly recommend Next.js as step in the right direction.

Take a look on their website, look at the showcase for social proof, and of course if you want a bit more information without having to dig it up yourself, sign up for one of the Sudden Schools courses, and have it explained in short delightful videos.

Hope to see you soon!