# Setup A few steps are required before you can start using Kontrl. ## Install the plugin ``` npm install kontrl ``` ## Create an app 1. **Log in** to kontrl at [https://kontrlpanel.com](https://kontrlpanel.com/) 2. If you haven't already **create an app**. 3. Grab your **"Development token"** from the app settings. ## Connect To connect your application add the following code to your application. ```js // Require the kontrl library const kontrl = require("kontrl"); // settings go here kontrl.connect("YOUR_DEVELOPMENT_TOKEN"); ``` ## Start your application Once you've followed these steps you can **start** your application. The Kontrl plugin will then print the url to which you can connect **in the console**. ## Production mode Once you're ready to deploy your application you can **swap out** your development token for your **live token**. When you use your live token, Kontrl will assume the application is **running in production** meaning you can see and manage the running instances on [https://kontrlpanel.com](https://kontrlpanel.com). ```js kontrl.connect("YOUR_LIVE_TOKEN"); ``` When you are in **live mode** you will not get a url to connect to in the console for obvious security reasons. Instead you can view your app by **logging in** to [https://kontrlpanel.com](https://kontrlpanel.com) and choosing the right app. ## Staging mode The **Start-up** and **Business** plans have access to a separate **staging environment**. This is an environment with a **seperate url** from the production environment. To start an app in staging mode, go to your **app settings** page and copy the **staging token**. Then just use it with kontrl.connect() ```js Kontrl.connect("YOUR_STAGING_TOKEN") ``` ## Development mode There is a special environment for development. To start using the development environment, go to the **app settings** page and take a **development token**. You can then use kontrl.connect() ```js kontrl.connect("YOUR_DEV_TOKEN") ``` Once you start your app, a **URL** will get printed in the **console**. You can use this **url to visit your app** in development, as well as **send it to other people** to look at. This will **not change anything** about your **production or staging** environment. ## Security We suggest adding your **development token** and your **live token** as an **environment variable**. ```js kontrl.connect(process.env.KONTRL_TOKEN); ``` You can then use something like [dotenv](https://www.npmjs.com/package/dotenv) to store your development token. ## File structure We suggest putting your kontrl setup in a **different file** from the rest of your application. Here is a suggestion on how to get that done. ```js // admin.js const kontrl = require("kontrl"); module.exports = () => { // Kontrl setup kontrl.connect("YOUR_TOKEN"); } ``` This file can then be imported somewhere else. ```js // index.js const admin = require("admin.js") admin(); ```