Rewrite From Backbone to React – Best Practices
Sat Aug 31 2019
The “rewrite” options:
Write From Scratch That may sound as the best option at first. But 99% of the times your estimates will be way off and you will get stuck for a long with the need of supporting two “apps” at once. You may “hold off” with new features on the legacy app, but as time goes by and the “new app” is not production ready. You will start feeling the pressure of the need to provide functionality to the legacy app. If you have a relative “small-medium” app be sure to plan way in advance what is needed before going in this approach. It’s not fun building two apps at once.
Dual App This approach has more “wiggle” room. You decide to use your legacy app and start building new features inside it with the new tech stack. In this way you are not forced on providing features in two different apps as its the same one. As you progress and you have other features extended you can plan out and rewrite that specific feature in the new tech stack. You may get stuck for a long time with old stack in some places but probably those are spots that has less “traction” or require a lot of time to rewrite. Be sure if you go on this route to have some plans and goals. As the move to the new stack can literally never get “finished” as you have no pressure changing parts of the app as the “just work” and the refactor work will always get backlogged as there will be other more urgent items.
What We did? We went with the second approach, you probably felt that with my writing above, so I’m quite unbiased 🙂 But we surely had the discussion on which approach to take and luckily we went with that route. We create new routes inside backbone that will load a react app inside the backbone template. Inside that page backbone wont do anything. React will handle the rest and all the “internal” routing”. When user routed out off that react part, backbone will get back to action. Users wouldn’t have any change in their UX and we can provide better tools and much faster.