Hulu makes TV and movies easily accessible online — a feat which would be impossible without powerful engineering practices and tools. While the team at Hulu has been using Next.js since it's initial release, they recently made a push to spread the framework deeply throughout their organization. Next.js gave Hulu the confidence to migrate to a modern frontend environment, all while reducing their code surface area and shipping faster in the process.
At the beginning of 2018, senior software engineer Zack Tanner and team began leading the migration of the Hulu Account app off of a legacy tech-stack, with the goal of unifying the developer organization and modernizing their code in an effort to prevent bugs and increase velocity.
Hulu had already been using Next.js for greenfield applications, so it was an obvious option when it came to choosing which framework to move to. This time, however, the team needed to migrate an existing production app—a challenge that comes with new difficulties of its own.
One of the most common challenges teams face when executing an incremental migration is handling the transition between the new and old systems. Fortunately, with Next.js there was never an issue with running both versions at once. With out-of-the-box support for prefetching new pages while jumping into the legacy app when needed, Zack and the team were able to easily migrate pages one-by-one. And since the intermediary hybrid-site was intelligently routed by Next.js, there was no need to maintain the overhead of explicitly tracking the migration's progress in the code itself.
In fact, throughout the migration, the ability of Next.js to make the extraction of common issues and patterns as easy as possible was a recurring theme. With each new version of Next.js, Zack and the team found they were constantly deleting internal code in favor of framework integrated tooling. Whenever the team needed to incorporate a new technology, Next.js had either first-class support or an endorsed example for them to follow.
“Productivity has skyrocketed. We’re able to focus on feature development and improving our product, while Next.js handles the more difficult tooling for us.”Zack Tanner, Hulu Senior Software Engineer
Zack also found that Next.js helps developers avoid common pitfalls. By having a single abstraction for handling difficult UI tasks, Next.js prevents developers from introducing problems incidentally—for example from over-fetching deep in the component tree. If a developer needed to fetch new data, they knew exactly where to look. Nobody needed to learn any of the cumbersome underlying APIs and the team could trust Next.js to handle the hard parts.
A critical requirement for Hulu was server-side rendering. With data coming from many sources and a fundamental need for SEO, server-side rendering was a must. With other frameworks, server-rendering pages with complex data dependencies is difficult and error prone, if not impossible. Next.js however made the process straightforward.
“[Server rendering] was as easy as moving data fetching from one spot to another. Next.js dealt with the underlying client hydration, while giving us a single abstraction to handle our data fetching logic.”— Zack Tanner
Even when issues arose, Zack found that error tracing with server-rendered pages was far superior compared to any other solution he'd tried. By acting as a unified tool for managing both client and server-side rendering, Next.js makes it easy for developers to tap into the rich benefits of server-side rendering, while still working in familiar territory of writing client side code.
Finally, by using the CSS-in-JS solution that Next.js provides by default, Zack and team were able to implement optimized styles that were code-split automatically. This meant each page would load only the CSS it needed, keeping page-size small without compromising on functionality. The Hulu teams also extended these defaults using sanctioned
next-plugins, enhancing their setup to support existing global Sass files with minimal overhead.
One year into their journey, Zack credits Next.js for fewer bugs, greater productivity, and a happier engineering organization. As Next.js continues to improve, the Hulu team is excited to continually reap the rewards, passing them on to their users in the form of a more robust, and featureful platform.