➡️ Migrating to Sensible
There's a lot of steps involved in migrating an existing codebase to start using Sensible. It can be divided into two parts: getting your old codebase to run, and refactoring it to make good use of all sensible features.
Getting it to run
- The easiest way is to just run
sensible init
to create a new project. - You can get your old codebase to run by simply copying your server and frontend(s) to the
apps
folder. It is advisable to use different folder-names and leaveapp
,web
andserver
in there, so you still have the examples of how to do it properly, for later. - Fix package versioning problems (you can just have one version per package, or you need to use nohoist
- Deploy it all with this new monorepo.
Refactoring it sensibly
Easy enough, but you're not done! To use sensible in a sensible way, you need to:
- Put all type interfaces that need to be used in multiple apps, frontend and backend, inside
core
so they can be used everywhere. Remove type interfaces everywhere else, and use thecore
ones. - Create endpoint definitions in core for all your endppoints
- Use the
core
definitions in the frontend: start using theapi
function everywhere. - Refactor all your endpoints to use
makeEndpoint
. - Put all your UI (screens, components, hooks, storage) in the
ui
package so they can be reused across different frontends. - If you also want to reuse
ui
betweenreact
andreact-native
, you need to start usingreact-with-native
.
This may seem like a daunting task, and it probably is. If you need help, don't hestitate to contact us. We would love to learn more about making migrations to Sensible easier. We'll even help you for free to a certain point!