How do I set the environment through code?

I’ve gone through the Realm Documentation and from what I understand, you can only use one environment for each app at a time. But I’d like to change the environment when I’m developing it locally without causing issues to the production.

Even if I were to create a new app for development or production, do I have to copy over functions/triggers etc from development to production?

I was wondering if there’s a way to change the app environment based on “.env.local” file that I use for secrets when developing.

Stack I’m using:
Next.js with Realm and Atlas