API Reference

Nuxt

This document provides instructions for working with Nuxt.js and the CommandK CLI. It explains how to run your Nuxt.js application and manage secrets effectively using the CommandK CLI.

Prerequisites

Before you begin the integration process, make sure you have the following:

  1. API Access Token: To authenticate your Nuxt.js application with CommandK, you'll need an API access token. If you haven't obtained one yet, refer to this link for instructions on how to acquire it.

Integration Steps

Follow these steps to integrate CommandK with your Nuxt.js application:

Step 1: Create a Nuxt.js Application

If you haven't already created a Nuxt.js application, you can set up a new project using the Nuxt.js CLI by following these steps:

  1. Install the Nuxt.js CLI globally if you haven't already:

    npm install -g create-nuxt-app
    
  2. Create a new Nuxt.js project using the following command:

    npx create-nuxt-app my-nuxt-app
    

    Replace my-nuxt-app with your desired project name.

  3. Follow the prompts to configure your Nuxt.js project. You can choose options such as UI framework, rendering mode, and more based on your project requirements.

Step 2: Access Secrets in Your Nuxt.js Application

Inside your Nuxt.js application, you can access secrets as environment variables. Open your Nuxt.js configuration file (usually nuxt.config.js) and add the following code snippet:

export default {
  // Other Nuxt.js configuration options...

  env: {
    SECRET_KEY: process.env.COMMANDK_SECRET_KEY || 'default-secret'
  }
}

In this code, COMMANDK_SECRET_KEY is the environment variable that will store your secret. If the variable is not found, it falls back to a default value ('default-secret').

Running Your Nuxt.js Application

To run your Nuxt.js application with the CommandK CLI, you can use the following command:

$ cmdk run <application-name> --environment development -- npm run dev

Replace <application-name> with the actual name of your Nuxt.js application. This command will execute your Nuxt.js application in the development environment.

Running with dotenv

If your Nuxt.js application uses dotenv to manage environment variables, you can utilize the CommandK CLI to write these variables to a .env file and then run your service. Follow these steps:

  1. Execute the following command:
$ cmdk run <application-name> --environment development \
     --run-type file-store \
     --file-name .env.local \
     --file-format env \
     -- npm run dev

Replace <application-name> with the actual name of your Nuxt.js application. This command will write your environment variables to the .env.local file in the specified env format and then run your Nuxt.js service.

Adjust the file name and format to match your project's configuration if necessary.

By following these instructions, you can seamlessly integrate the CommandK CLI with your Nuxt.js application, making it easy to manage secrets and run your application securely.