Skip to main content

Overview

Add your Invent AI assistant to any Nuxt 3 application. Perfect for Vue.js applications with server-side rendering and static generation.

Installation

1

Create Assistant Component

2

Add to App Layout

3

Configure Environment

Add to nuxt.config.ts:
Add to .env:

User Authentication

Security Requirement: When using any user-* attributes (user-id, user-name, user-avatar), you must also provide user-hash. Both user-id and user-hash must be provided together, or neither should be provided. The user-hash must be generated on your backend using HMAC-SHA256 with your assistant’s secret key. Never expose the secret key to the client.

Server-Side Hash Generation

Use Nuxt server routes to generate the hash securely:

Using in Component

Integration with Nuxt Auth

Using @sidebase/nuxt-auth

TypeScript Support

Add type declarations:

Composable for Authentication

Create a reusable composable:
Usage:

Tips for Nuxt

Server Routes

Use server routes for secure hash generation

Composables

Create reusable composables for auth logic

SSR Compatible

Works with SSR, SSG, and SPA modes

Type Safe

Full TypeScript support

Troubleshooting

Solutions:
  • Ensure plugin is client-side only (.client.ts)
  • Check that script loads after component mounts
  • Verify URL is correct
  • Check browser console for errors
Solutions:
  • Use ClientOnly component if needed
  • Ensure script loads client-side only
  • Check that user data is fetched client-side
Solutions:
  • Restart dev server after adding env variables
  • Check nuxt.config.ts runtimeConfig
  • Use NUXT_PUBLIC_ prefix for public variables
  • Keep secret key private (no prefix)

Best Practices

  • Use server routes for hash generation
  • Keep secret key in .env (never commit)
  • Use composables for reusable logic
  • Test in both SSR and SPA modes
  • Leverage Nuxt’s built-in security features