Skip to content
All projects

Dcard · 2023 · Frontend migration

Next.js Native Router Migration

Moved Dcard's sites off a homemade router and onto the router built into Next.js.

Next.js Native Router Migration thumbnail with a sample route list, three routes on the Next.js router and one awaiting a redirect check
Built at
Dcard
When
2023
Built with

Background

The system was built before Next.js shipped its own router, so it ran on a homemade one. Once the official router came out, the team wanted to move away from the homemade router to reduce maintenance costs.

What I did

  • Clarified what the homemade router did, so every function could be converted.
  • Wrote migration documents so other participants could migrate features by following them.

Problems along the way

The homemade router had special redirect handling

During the migration both routers were in use, and every site shared the same version of the homemade router. When handling its special redirects, I had to make sure other sites were not affected and that the routes already moved over still worked.

Dcard Pixel thumbnail with a sample embed code snippet above PageView and ViewContent events

Dcard · 2021-2025

Dcard Pixel

The tracking code business customers add to their websites to measure ad conversions.

  • JavaScript SDK
  • npm