Expo Router introduces a new way to handle deep links in React Native applications. However, migrating from the old approach can be challenging, especially when trying to avoid a freeze window. Say you are a React Native developer tasked with migrating your app's deep link handling to Expo Router without disrupting user experience.
The Situation
You are working on a React Native app that uses the old deep link handling approach. Your team wants to migrate to Expo Router to take advantage of its features, but you cannot afford to have a freeze window where no updates can be made to the app. You try to migrate the deep link handling, but you encounter issues with routing and linking. The symptom is that some deep links are not working as expected, and you are seeing errors in the console. This is costing you time and potentially losing users who are trying to access specific parts of your app.
Why It Happens
The old deep link handling approach and Expo Router have different architectures and APIs. Expo Router uses a more modular and flexible approach to handling deep links, which requires changes to the app's routing and linking setup. When migrating, it's easy to introduce errors or inconsistencies that can break deep links. Additionally, Expo Router has specific requirements for setting up deep links, such as configuring the app.json file and using the Linking API correctly.
The Fix, Step by Step
To migrate to Expo Router without a freeze window, follow these steps:
-
Set up Expo Router: First, install Expo Router and set it up in your app. This involves creating a new
router.jsfile and configuring theapp.jsonfile to use Expo Router. - Migrate deep link handling incrementally: Instead of migrating all deep links at once, do it incrementally. Start by migrating a small subset of deep links to Expo Router and test them thoroughly. This will help you identify and fix any issues before migrating the rest of the deep links.
- Use a fallback mechanism: Implement a fallback mechanism to handle deep links that are not yet migrated to Expo Router. This can be done by using the old deep link handling approach for unmigrated links.
- Test and iterate: Test the migrated deep links and iterate on the process until all deep links are working correctly with Expo Router.
- Remove the old approach: Once all deep links are migrated, remove the old deep link handling approach to avoid maintaining two different systems.
What It Costs, and When Not to Do It
Migrating to Expo Router requires time and effort, especially if you have a large number of deep links to migrate. However, the benefits of using Expo Router, such as improved flexibility and modularity, make it a worthwhile investment. You should not migrate to Expo Router if you have a very small number of deep links or if you are close to a major release and cannot afford to introduce changes to your app's routing and linking setup.
At Your Level
- Starting out: Focus on understanding the basics of Expo Router and how it handles deep links. Start by migrating a small subset of deep links and testing them thoroughly.
- Working engineer: You should be able to migrate your app's deep link handling to Expo Router without disrupting user experience. Focus on testing and iterating on the process to ensure that all deep links are working correctly.
- Senior or staff: You should be able to architect a migration plan that minimizes downtime and ensures a smooth transition to Expo Router. Consider the trade-offs between migrating incrementally and doing a big-bang migration.
- Lead or director: You should be able to prioritize the migration to Expo Router based on business needs and technical requirements. Consider the cost of migration and the benefits of using Expo Router, and make an informed decision about whether to migrate and when.
In the Interview
An interviewer may ask you to describe a situation where you had to migrate a complex system without downtime. A weak answer might focus on the technical details of the migration without considering the broader implications. A strong answer would discuss the trade-offs between different migration approaches, the potential risks and benefits, and the steps taken to mitigate those risks. For example:
Interviewer: "Can you describe a situation where you had to migrate a complex system without downtime?"
Weak answer: "We used Expo Router to handle deep links and it worked fine."
Strong answer: "We had to migrate our app's deep link handling to Expo Router without disrupting user experience. We decided to migrate incrementally, starting with a small subset of deep links, and tested them thoroughly to ensure that they were working correctly. We also implemented a fallback mechanism to handle deep links that were not yet migrated. The migration took several weeks, but it was worth it to ensure a smooth transition to Expo Router."
Amit Chakraborty is a founding engineer and senior architect — React Native, AI/RAG systems and production architecture. Portfolio: www.amitchakraborty.dev · LinkedIn · GitHub. Open to senior and founding engineering roles, remote worldwide.
Top comments (0)