Apps & environments

Begin applications are instances of codebases that can have one or more deployment environments (for example, staging and production).

Creating an app

To create a new Begin app, you’ll use the Begin CLI. In order to create a new app, you’ll need to be in the root folder of your project.

The begin create command will ask you a few questions in order to configure your application. For example:

begin create
This project doesn't appear to be associated with a Begin app
? Would you like to create a Begin app based on this project? (Y/n) y

? What would you like to name your app? begin-example-app

? What would you like to name your first environment? staging

Added appID 'XXXXXXXXX' to project, be sure to commit this change!
App 'begin-example-app' + environment 'staging' created at https://local-fih.begin.app

? Would you like to deploy your app? (Y/n) n
You can deploy at any time by running: begin deploy
npx begin create
This project doesn't appear to be associated with a Begin app
? Would you like to create a Begin app based on this project? (Y/n) y

? What would you like to name your app? begin-example-app

? What would you like to name your first environment? staging

Added appID 'XXXXXXXXX' to project, be sure to commit this change!
App 'begin-example-app' + environment 'staging' created at https://local-fih.begin.app

? Would you like to deploy your app? (Y/n) n
You can deploy at any time by running: begin deploy

After the command finishes, you’ll have a new app on Begin with a staging environment.

The begin create command will add a new @begin pragma to your project’s .arc file with the project’s new appID. Make sure you commit this change to source code control.

Listing your apps

You can list all of the apps created under your account (and their environments) using the begin list command.

begin list
begin-example-app (app ID: XXXXXXXXX)
└── staging (env ID: STGXXXXXX): https://local-fih.begin.app
another-app (app ID: XXXXXXXXX)
└── staging (env ID: STGXXXXXX): https://airy-zko.begin.app
└── production (env ID: PRDXXXXXX): https://my-app.com
npx begin list
begin-example-app (app ID: XXXXXXXXX)
└── staging (env ID: STGXXXXXX): https://local-fih.begin.app
another-app (app ID: XXXXXXXXX)
└── staging (env ID: STGXXXXXX): https://airy-zko.begin.app
└── production (env ID: PRDXXXXXX): https://my-app.com

Deleting an app

If you decide you no longer need an application under your account, you can delete it by running begin destroy. (Note that this command does not delete your project code. Only the application ID and the application’s environments will be destroyed.)

begin destroy -a XXXXXXXXX
? Are you sure you want to destroy this Begin app
(name: 'begin-example-app', ID: 'XXXXXXXXX') and its 1 environment? › XXXXXXXXX
Destroyed Begin app ID 'XXXXXXXXX'
npx begin destroy -a XXXXXXXXX
? Are you sure you want to destroy this Begin app
(name: 'begin-example-app', ID: 'XXXXXXXXX') and its 1 environment? › XXXXXXXXX
Destroyed Begin app ID 'XXXXXXXXX'

There is no way to recover your application once you delete it from Begin! If you have mistakenly deleted an app, you’ll need to create a new app and deploy it to Begin.

Creating an environment

Most applications will require multiple environments — for example, staging and production.

Let’s create a production environment for your app using the CLI. If you’re in the root folder of you application, you can run:

begin create --env production
npx begin create --env production

If you aren’t in the root folder of your application when you run the begin create --env command, you’ll need to specify the application ID that you want to create the environment for.

begin create --app XXXXXXXX --env production
npx begin create --app XXXXXXXX --env production

You should now have a new environment called production under your app. You can verify this using the begin list command mentioned above.

Deleting an environment

To remove an environment from your application, use the begin destroy command with the --env flag.

begin destroy --env PRODXXXX
? Are you sure you want to destroy this Begin app environment
(env name: 'production', env ID: 'PRODXXXX')? · PRODXXXX
Destroyed Begin app environment (env name: 'production', env ID: 'PRODXXXX')
npx begin destroy --env PRODXXXX
? Are you sure you want to destroy this Begin app environment
(env name: 'production', env ID: 'PRODXXXX')? · PRODXXXX
Destroyed Begin app environment (env name: 'production', env ID: 'PRODXXXX')

If you are not in the app’s root folder when running this command, you’ll need to specify the app ID as well.

begin destroy --app XXXXXXXX --env PRODXXXX
? Are you sure you want to destroy this Begin app environment
(env name: 'production', env ID: 'PRODXXXX')? · PRODXXXX
Destroyed Begin app environment (env name: 'production', env ID: 'PRODXXXX')
npx begin destroy --app XXXXXXXX --env PRODXXXX
? Are you sure you want to destroy this Begin app environment
(env name: 'production', env ID: 'PRODXXXX')? · PRODXXXX
Destroyed Begin app environment (env name: 'production', env ID: 'PRODXXXX')