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

# Deploy on Vercel and Convex

> Deploy Nudgra Cloud with Vercel, Convex Auth, and Convex production environment variables.

This is the recommended production path for Nudgra Cloud. Host the Next.js app on Vercel and run backend state, auth, scheduling, and webhooks on Convex Cloud.

## Prerequisites

Before you start, prepare:

* A Convex account.
* A Vercel account.
* A public app domain, such as `https://cloud.nudgra.example.com`.
* Google OAuth credentials.
* Meta app credentials and a webhook verify token.

## Choose the app domain

Pick the final public URL for the Next.js app:

```text theme={null}
https://your-app-domain.com
```

Use that exact value everywhere:

* Vercel `SITE_URL`.
* Convex production `SITE_URL`.
* Meta OAuth redirect URI.
* Google authorized JavaScript origin.
* Tracked-link testing.

If the domain changes later, update all platform settings and redeploy.

## Create the Convex production deployment

<Steps>
  <Step title="Create the deployment">
    Create or open your Convex project. Create a production deployment from the Convex dashboard.
  </Step>

  <Step title="Generate a deploy key">
    Generate a production deploy key from the Convex dashboard. You will set it as `CONVEX_DEPLOY_KEY` on Vercel.
  </Step>

  <Step title="Save the site URL">
    Keep the production deployment's `.convex.site` URL handy. You need it for Google OAuth and Meta webhooks.
  </Step>
</Steps>

You can also open the dashboard from the project root:

```bash theme={null}
npx convex dashboard
```

## Provision Convex Auth

Run this from the project root:

```bash theme={null}
npx @convex-dev/auth --prod
```

When prompted:

* Set `SITE_URL` to your public app domain, such as `https://your-app-domain.com`.
* Let the tool generate and store `JWT_PRIVATE_KEY` and `JWKS`.

This prepares the production Convex deployment for Google sign-in and redirects back to your app after auth.

## Configure Convex production

Set the email allowlist:

```bash theme={null}
npx convex env set --prod NUDGRA_ALLOWED_EMAILS your-google-email@gmail.com
```

Set the public app origin:

```bash theme={null}
npx convex env set --prod SITE_URL https://your-app-domain.com
```

After Google and Meta setup, also set:

```bash theme={null}
npx convex env set --prod AUTH_GOOGLE_ID your-google-client-id
npx convex env set --prod AUTH_GOOGLE_SECRET your-google-client-secret
npx convex env set --prod META_APP_ID your-instagram-app-id
npx convex env set --prod META_APP_SECRET your-instagram-app-secret
npx convex env set --prod META_VERIFY_TOKEN your-random-verify-token
```

## Deploy on Vercel

<Steps>
  <Step title="Import the repository">
    Import the Nudgra Cloud repository into Vercel.
  </Step>

  <Step title="Set the install command">
    ```bash theme={null}
    npm install
    ```
  </Step>

  <Step title="Set the build command">
    ```bash theme={null}
    npx convex deploy --cmd "npm run build"
    ```
  </Step>

  <Step title="Set Vercel environment variables">
    ```env theme={null}
    CONVEX_DEPLOY_KEY=your-convex-production-deploy-key
    SITE_URL=https://your-app-domain.com
    META_APP_ID=your-instagram-app-id
    META_APP_SECRET=your-instagram-app-secret
    META_VERIFY_TOKEN=your-random-webhook-verify-token
    ```
  </Step>

  <Step title="Attach the production domain">
    Attach the final domain in Vercel, then redeploy after the domain and environment variables are final.
  </Step>
</Steps>

The build command deploys the Convex backend, typechecks and bundles Convex functions, and injects the correct Convex deployment URLs into the Next.js build.

## Smoke test production

After the first deployment:

1. Open `https://your-app-domain.com`.
2. Sign in with a Google account listed in `NUDGRA_ALLOWED_EMAILS`.
3. Open `/dashboard/account`.
4. Connect an Instagram professional account.
5. Confirm the account appears as connected.
6. Send a real test DM, comment, or story reply.
7. Verify that contacts, conversations, automations, and logs update in the dashboard.
8. Verify that tracked links resolve through your app domain.
9. Verify that webhook activity appears in logs.

## Update a deployment

For Vercel, push to the branch connected to the project and let the build run.

You can also deploy from the project root:

```bash theme={null}
npx convex deploy --cmd "npm run build"
```
