Switching between test/prod testnet/mainnet

Are there some proven patterns for switching between mainnet/testnet?
Since mainnet and testnet requires different appIds can I just swap them out / update them in the MoralisProvider when the user switches the chainId to testnet or should these be located on different sites?

If you’re wanting both a testnet server and mainnet server connection working together in the same app, you could try swapping out the server details in MoralisProvider based on the user’s current chain and set it in state (you could use Redux for example).

But it would be better to separate them into two distinct versions of your app e.g. testnet.yoursite.com.

1 Like