CLI

The StaticKit command line interface (CLI) comes with helpful commands for performing common tasks like adding a new form and adding a secret. You can use the CLI to make changes or edit your statickit.json file by hand — either way is fine!

CommandDescription
forms addAdd a form
secrets addAdd a secret
deployDeploy your config

Installation

Install the command line interface with npm:

npm i -g @statickit/cli

Add a form

Run the following command to add a new form to your config file.

statickit forms add <key> <name>

If you'd like to add extra functionality (like server-side validations and actions), you can edit the config manually.

Example

The following command will change your statickit.json file like this:

statickit forms add contact-form "Contact Form"
  {
    "forms": {
+     "contact-form": {
+       "name": "Contact Form"
+     }
    }
  }

Add a secret

Secrets are used to store values that are too sensitive to put in version control, like API keys for external services.

Run the following command to add a secret to your site:

statickit secrets add <name> <value>

Example

The Mailchimp integration needs an API key in order to communicate with your account. This command will create a secret called mailchimp-api-key:

statickit secrets add mailchimp-api-key "jf89s..."

Then, in your form config, you can reference the secret you just added (notice the @-symbol prefix).

  {
    "forms": {
      "newsletter": {
        "name": "Newsletter",
        "actions": [
          {
            "app": "mailchimp",
            "type": "addOrUpdateContact",
+           "apiKey": "@mailchimp-api-key"
          }
        ]
      }
    }
  }

Deploy

Once you are finished making changes to your local config file, you must deploy them to StaticKit with the CLI.

statickit deploy -k <your-deploy-key>

Your site's deploy key can be found under the Settings tab in StaticKit. Instead of using the -k flag every time, you can create a .env file in the root of your project and define an environment variable:

echo "STATICKIT_DEPLOY_KEY=<your-deploy-key>" >> .env
echo ".env" >> .gitignore

Do not commit your .env file to version control. You should treat your deploy key like any other secret token. A common convention is to create a .env.example file (excluding the actual key) that developers can use as a template:

echo "STATICKIT_DEPLOY_KEY=" >> .env.example