> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aikocorp.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Monitor Quickstart

> Get started with AIKO Monitor in minutes

## Prerequisites

* An AIKO project with your **project key** and **secret key**
* A web application using one of our supported frameworks:
  * Next.js
  * Express
  * FastAPI
  * Flask
  * Actix Web
  * Your framework is missing? [Let us know](https://discord.com/invite/aikocorp) what we should add next!

<AccordionGroup>
  <Accordion title="Where to find your project key and secret key">
    If you missed copying your keys from the onboarding step when creating a project, you can find them again in Settings → [Projects](https://app.aikocorp.ai/settings/projects):

    <video controls className="w-full" src="https://mintcdn.com/aiko/tYUoq4ayo7oScgc5/aiko_project_key_settings.mp4?fit=max&auto=format&n=tYUoq4ayo7oScgc5&q=85&s=90556a38551997ccf9e02a486e78c98b" data-path="aiko_project_key_settings.mp4">
      Your browser does not support the video tag.
    </video>
  </Accordion>
</AccordionGroup>

## Quick Setup with Wizard

The fastest way to get started is with our setup wizard—it handles authentication, project setup, and configuration in one go. Just run this from your project root:

```bash theme={null}
npx aiko-monitor-wizard
```

Once setup is complete, you will need to send a test request to your API and wait about 30 seconds for events to show up in the dashboard.

<AccordionGroup>
  <Accordion title="Grouping apps in one project">
    If you have multiple customer-facing products, it's best to install AIKO Monitor on them all and group them in one project.

    This makes it possible to track users across their entire journey (e.g. from visiting your landing page to signing up for your product).
  </Accordion>
</AccordionGroup>

## Manual Installation

If you'd prefer manual steps (or if the wizard doesn't fit your setup), you can follow the steps below for your framework.

<Tabs>
  <Tab title="Next.js">
    <Steps>
      <Step title="Install the package">
        Install AIKO Monitor via npm:

        ```bash theme={null}
        npm install aiko-monitor
        ```
      </Step>

      <Step title="Create .env file">
        Create a `.env` file in your project root with your AIKO credentials:

        ```bash theme={null}
        # .env
        AIKO_PROJECT_KEY="<project_key>"
        AIKO_SECRET_KEY="<secret_key>"
        ```
      </Step>

      <Step title="Initialize in your app">
        Create an `instrumentation.ts` file in your project root and initialize AIKO Monitor:

        ```typescript theme={null}
        // instrumentation.ts
        export async function register() {
          if (process.env.NEXT_RUNTIME === "nodejs") {
            const aiko = await import("aiko-monitor");

            const monitor = aiko.default.init({
              projectKey: process.env.AIKO_PROJECT_KEY,
              secretKey: process.env.AIKO_SECRET_KEY,
            });

            monitor.instrumentNextJs();
          }
        }
        ```

        Then create your API routes as usual:

        ```typescript theme={null}
        // app/api/users/route.ts
        export async function GET() {
          const users = [{ id: 1, name: "John Doe" }];
          return Response.json({users});
        }
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="Express">
    <Steps>
      <Step title="Install the package">
        Install AIKO Monitor via npm:

        ```bash theme={null}
        npm install aiko-monitor
        ```
      </Step>

      <Step title="Create .env file">
        Create a `.env` file in your project root with your AIKO credentials:

        ```bash theme={null}
        # .env
        AIKO_PROJECT_KEY="<project_key>"
        AIKO_SECRET_KEY="<secret_key>"
        ```
      </Step>

      <Step title="Initialize in your app">
        Import and initialize AIKO Monitor in your Express application. The monitor middleware must be the first middleware:

        ```javascript theme={null}
        // server.js
        import dotenv from "dotenv";
        dotenv.config();
        import express from "express";
        import aiko from "aiko-monitor";

        const app = express();

        const monitor = aiko.init({
          projectKey: process.env.AIKO_PROJECT_KEY,
          secretKey: process.env.AIKO_SECRET_KEY,
        });

        app.use(monitor.middleware()); // must be the first middleware
        app.use(express.json());

        app.get("/api/users", (req, res) => {
          res.json({ users: [{ id: 1, name: "John Doe" }] });
        });

        app.listen(3000);
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="FastAPI">
    <Steps>
      <Step title="Install the package">
        Install AIKO Monitor via pip:

        ```bash theme={null}
        pip install aiko-monitor
        ```
      </Step>

      <Step title="Create .env file">
        Create a `.env` file in your project root with your AIKO credentials:

        ```bash theme={null}
        # .env
        AIKO_PROJECT_KEY="<project_key>"
        AIKO_SECRET_KEY="<secret_key>"
        ```
      </Step>

      <Step title="Initialize in your app">
        Import and initialize AIKO Monitor in your FastAPI application:

        ```python theme={null}
        # main.py
        import os
        from dotenv import load_dotenv
        from fastapi import FastAPI
        from aiko_monitor import Monitor

        load_dotenv()

        app = FastAPI()
        Monitor(
            app,
            project_key=os.getenv("AIKO_PROJECT_KEY"),
            secret_key=os.getenv("AIKO_SECRET_KEY"),
        )

        @app.get("/api/users")
        def get_users():
            return {"users": []}
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="Flask">
    <Steps>
      <Step title="Install the package">
        Install AIKO Monitor via pip:

        ```bash theme={null}
        pip install aiko-monitor
        ```
      </Step>

      <Step title="Create .env file">
        Create a `.env` file in your project root with your AIKO credentials:

        ```bash theme={null}
        # .env
        AIKO_PROJECT_KEY="<project_key>"
        AIKO_SECRET_KEY="<secret_key>"
        ```
      </Step>

      <Step title="Initialize in your app">
        Import and initialize AIKO Monitor in your Flask application:

        ```python theme={null}
        # app.py
        import os
        from dotenv import load_dotenv
        from flask import Flask
        from aiko_monitor import Monitor

        load_dotenv()

        app = Flask(__name__)
        Monitor(
            app,
            project_key=os.getenv("AIKO_PROJECT_KEY"),
            secret_key=os.getenv("AIKO_SECRET_KEY"),
        )

        @app.route("/api/users")
        def get_users():
            return {"users": []}
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="Actix Web">
    <Steps>
      <Step title="Install the package">
        Add AIKO Monitor to your Cargo.toml with the required features:

        ```bash theme={null}
        cargo add aiko-monitor --features actix
        ```

        Or add this to your `Cargo.toml`:

        ```toml theme={null}
        [dependencies]
        aiko-monitor = { version = "0.0.1", features = ["actix"] }
        ```
      </Step>

      <Step title="Create .env file">
        Create a `.env` file in your project root with your AIKO credentials:

        ```bash theme={null}
        # .env
        AIKO_PROJECT_KEY="<project_key>"
        AIKO_SECRET_KEY="<secret_key>"
        ```
      </Step>

      <Step title="Initialize in your app">
        Import and wrap your Actix Web application with the AIKO Monitor middleware:

        ```rust theme={null}
        // src/main.rs
        use std::env;
        use std::io::Result as IoResult;

        use actix_web::middleware::Logger;
        use actix_web::{App, HttpResponse, HttpServer, Responder, web};
        use aiko_monitor::{Monitor, integrations::actix::MonitorActix};
        use dotenvy::dotenv;

        async fn get_users() -> impl Responder {
            HttpResponse::Ok()
                .content_type("application/json")
                .body(r#"{"users": []}"#)
        }

        #[actix_web::main]
        async fn main() -> IoResult<()> {
            dotenv().ok();

            let monitor = Monitor::new(
                env::var("AIKO_PROJECT_KEY").expect("AIKO_PROJECT_KEY must be set"),
                env::var("AIKO_SECRET_KEY").expect("AIKO_SECRET_KEY must be set"),
            )
            .expect("valid monitor configuration");

            HttpServer::new(move || {
                let monitor = monitor.clone();
                App::new()
                    .wrap(Logger::default())
                    .wrap(MonitorActix::new(monitor))
                    .route("/api/users", web::get().to(get_users))
            })
            .bind(("127.0.0.1", 3000))?
            .run()
            .await
        }
        ```
      </Step>
    </Steps>
  </Tab>
</Tabs>

## Next steps

<CardGroup cols={2}>
  <Card title="Monitor Features" icon="list-check" href="/aiko/monitor/features">
    Learn about all monitoring capabilities
  </Card>
</CardGroup>
