safe-global / safe-wallet-web

Safe{Wallet} – smart contract wallet for Ethereum (ex-Gnosis Safe multisig)
https://app.safe.global
GNU General Public License v3.0
316 stars 379 forks source link

Fetch chains config on build time (and after revalidation) #3752

Open usame-algan opened 1 month ago

usame-algan commented 1 month ago

What is the feature about

We currently fetch the chains config on runtime whenever the app loads. The chains config includes data that is needed in many different places of the app and is used for fetching the safe info, feature flags, rpc etc so it effectively "stalls" the app. However, the chains config doesn't change often so we should check if this can be optimized. A few examples when changes are necessary:

Next.js offers something called Incremental Static Regeneration (ISR) which would allow us to only fetch the chains config on build time or after some fixed revalidation time by regenerating static files without having to build the app again.

The list of requirements

usame-algan commented 1 month ago

Unfortunately it looks like this is not supported for SSG: https://nextjs.org/docs/pages/building-your-application/deploying/static-exports#unsupported-features

usame-algan commented 1 month ago

We could still fetch it on build time to ensure the data is there fast and then keep fetching it on app load like we do now to catch any updates. We need to add getStaticProps to every page file in order to fetch the data on build time. This seems quite cumbersome and is not necessary anymore with the new app router so I would suggest to first do the migration #2541