News for hackers. Stuff that matters.
Re:Next.js 11 by steve_adams_86 on Tuesday June 15, 2021 @01:59PM (#27519063)
It's a fairly guard-railed, easy to deploy, React-based static site generator with dynamic content capabilities as well. It's generally great software. My team uses it for https://instantdomainsearch.com and we get good performance and developer experience overall.

To me it feels like the React "happy path" at the moment if you need a static or partially dynamic site/web application. I suppose the ideal use case is essentially any site you want to serve statically but maintain with React. This could be a blog, graphic design portfolio, or even a small store. It makes it easy for us to embed our React-based search application inside of a site with static content beside it that's easy to maintain and create.

Yeah, we could do this without next, but it provides some convention and well-made tools that generally make the job easier.

Re:Next.js 11 by vincentmarle on Tuesday June 15, 2021 @02:29PM (#27519534)
Cool, I'm a big fan of instantdomainsearch (it's my goto domain search tool) and had no idea how you can lookup the domains that fast. Is it fair to say that Next.js is a big part of that performance?
Re:Next.js 11 by steve_adams_86 on Tuesday June 15, 2021 @05:46PM (#27521923)
Next.js isn't a significant part of the run time performance of actual searching – that's fast because of a lot of custom infrastructure, data pre-processing, and client side code.

Next mostly makes it so pulling the site down and loading the page is snappier without us having to try particularly hard to get it that way. It isn't totally effortless - we've got some tailored pieces in our pipeline, but Next "off the shelf" does an excellent job already, and the work they've done makes customizations easy to implement and maintain.

I'm glad to hear you like it! Seriously, it makes it way more interesting knowing people are enjoying it. Every little tweak and improvement to performance is worth it when people are getting something out of it.

Re:Next.js 11 by bradhilton on Tuesday June 15, 2021 @06:20PM (#27522296)
I also really like instantdomainsearch.com. I don't have any specific feedback, but thank you for your team's work!
Re:Next.js 11 by steve_adams_86 on Tuesday June 15, 2021 @06:45PM (#27522569)
You’re welcome!
Re:Next.js 11 by notjustanymike on Tuesday June 15, 2021 @02:01PM (#27519106)
I've only ever used Gatsby with this, how does it compare?
Re:Next.js 11 by steve_adams_86 on Tuesday June 15, 2021 @02:14PM (#27519318)
Good question.

Our migration was fairly direct. We did it in around a week with some cleanup in the following week. There were analogous conventions throughout just about the entire migration, so they're very similar.

One thing we liked was better TypeScript support. We're big on types and proper support, and most of our company is based on TypeScript and Rust. Gatsby can use TS, but you need to set it up and we came across the odd hiccup in the tooling. Next supports this off the shelf and so far, it shows. We haven't had any issues with compilation anywhere in the pipeline or other tooling.

The way Next handles dynamic pages is different, and in my opinion nicer. It also supports something they call incremental static generation which allows pages to be served statically, but incrementally updated as dependent data changes. For example, you know the team in the lead will be the same for thousands of requests, so you might as well serve that statically until the leading team changes. Next will manage that content update for you while serving the content statically for as long as possible. When we migrated, Gatsby didn't support this feature.

Next handles pages differently in general. It maps your directory structure under /src/pages, so that /src/pages/hello-world.tsx will be yourwebsite.com/hello-world. It allows for dynamic content using a convention in which file names can represent a variable, where src/pages/foo/[bar].tsx will make it so [bar] is a variable in the query intercepted by getServerSideProps when you visit yourwebsite.com/foo/whatever.

Otherwise I think the main snag we had with Gatsby was that the team was slower to address issues, introduced bugs more frequently, and we began to see that it was impeding our progress. Our software was working independently of Gatsby and wasn't the issue, and no matter how closely we worked with the maintainers, we couldn't move the needle on any blocking issues. With Next it has been a much different story. Issues are unblocked routinely and the maintainers seem much more engaged and productive.

There's more, but those are the main differences that come to mind.

Re:Next.js 11 by 48309248302 on Tuesday June 15, 2021 @02:42PM (#27519702)
> Gatsby can use TS, but you need to set it up

I'm not sure how long ago you tried Gatsby, but TypeScript doesn't require setup anymore. Just change the file extensions to .tsx/.ts and it works. It also does incremental builds.

Gatsby handles pages in src/pages the same way except it doesn't use placeholders in the filenames. You generate dynamic pages by writing a function. Check out these videos.

https://egghead.io/courses/why-gatsby-uses-graphql-1c319a1c

Re:Next.js 11 by steve_adams_86 on Tuesday June 15, 2021 @05:48PM (#27521944)
Right, graphql - I'm not sure how I forgot about that. We really disliked this part of Gatsby, but I know some people really like it. I can't criticize it really - it probably comes down to preference.

I guess it's been longer than I thought! Incremental builds wasn't even on the roadmap when we migrated.

Re:Next.js 11 by 48309248302 on Tuesday June 15, 2021 @10:16PM (#27524139)
I guess it depends on what you're building. For me the graphql is one of the most useful features. I've only used Next a little, but much prefer Gatsby. I don't think Next is bad though.
Re:Next.js 11 by notjustanymike on Friday June 18, 2021 @04:20PM (#27554545)
This is a hell of an answer for a small question, I really appreciate your write-up!