# Install with AI Assistants

Ask your AI coding assistant to add the widget. It reads your project and places it.

Claude Code

In IDE

Copilot

In IDE

Cursor

In IDE

ChatGPT

Web Chat

## For Claude Code / Copilot / Cursor

First add your widget key to your .env file as ISSUECAPTURE_API_KEY, with your framework's public prefix if it needs one (NEXT_PUBLIC_, VITE_, PUBLIC_). Then paste this into your AI assistant:

```js
Install the IssueCapture bug reporting widget in this project.

The widget is an ES module served from https://issuecapture.com/widget.js. Loading it sets window.IssueCapture. Start it with IssueCapture.init({ apiKey }) and stop it with IssueCapture.destroy().

Plain HTML: add this before </body>:
<script type="module">
  import IssueCapture from 'https://issuecapture.com/widget.js';
  IssueCapture.init({ apiKey: 'KEY' });
</script>

Bundled apps (React, Next.js, Vue, Angular, Svelte): do not import the https URL in source files. Load it in the browser only, once, near the app root: create a <script type="module" src="https://issuecapture.com/widget.js"> element, call window.IssueCapture.init({ apiKey }) in its load event, and call window.IssueCapture.destroy() on teardown.

The API key is already in my .env file as ISSUECAPTURE_API_KEY, with my framework's public prefix if it needs one. Reference the variable. Do not write the key's value into code or files.
```

With the [IssueCapture MCP server](https://issuecapture.com/docs/install/ai-assistant) configured, the assistant can also detect your framework and generate the files for you.

1

AI detects your framework automatically

The MCP server writes framework-specific code for Next.js and React. Other stacks get the plain script-tag snippet

2

AI analyzes your codebase

Searches for existing feedback buttons, navigation structure

3

AI recommends best placement

Use existing button, auto-positioned, or custom trigger

4

AI generates and applies code

Framework-specific, TypeScript-ready, SSR-safe

## For ChatGPT / Claude Web

Copy this prompt and paste into your AI chat:

Installation Prompt

```
I need help installing the IssueCapture widget into my [FRAMEWORK] application.

The widget API key is already in my .env file as ISSUECAPTURE_API_KEY (with my framework's public prefix if it needs one, e.g. NEXT_PUBLIC_). Do not ask me to paste the key. Reference the variable from the environment and do not write the key's value into code or files.

Step 1: Analyze my codebase structure
- Look for layout/navigation components
- Search for existing feedback/bug report buttons or links
  - Text patterns: "feedback", "report bug", "help", "support"
  - ID/class patterns: feedback-btn, bug-report, support-link
- Identify the best placement strategy

Step 2: Recommend integration approach
Based on what you find, choose one:
- Option A: Use existing element (if found with confidence ≥60%)
- Option B: Auto-positioned floating button (if no existing element)
- Option C: Custom trigger in navigation (if consistent nav pattern)

Provide reasoning and alternatives.

Step 3: Generate installation code
- Follow [FRAMEWORK] best practices
- For Next.js: use 'use client', handle SSR properly
- For React: initialize in useEffect
- For Vanilla JS: use ES module imports
- Include TypeScript types if applicable
- Add environment variable for API key
- **If the app has authentication, prefill user data:**
  - Get user name and email from auth session
  - Pass to widget via 'user' config object
  - Listen for auth state changes to update widget
- Provide testing instructions

Step 4: Output format

Analysis:
- Detected structure: [describe]
- Existing elements found: [list with file paths]
- Recommendation: [Option A/B/C with reasoning]

Implementation:
[Code blocks with file paths]

Environment Variables:
[Where to add API key]

Testing:
[Step-by-step instructions]
```

**Tip:** Replace [FRAMEWORK] with your framework (Next.js, React, Vue, etc.)

**Before you paste:** copy your widget key from the API Keys tab and add it to your .env file as ISSUECAPTURE_API_KEY, so the prompt never needs the key itself. Widget keys are public, but keeping them out of chat logs is still good practice.

**Tip:** For better results, share your package.json and main component files

## What the AI Will Do

### Framework Detection

Automatically identifies your framework by analyzing package.json, config files, and project structure

Framework-specific code through the MCP server: Next.js and React (Vite/CRA). Vue, Angular, Svelte and other stacks get the plain script-tag snippet.

### Existing Element Detection

Searches your codebase for existing feedback or bug report buttons to maintain your UI

Scans navigation, headers, and layout components

### Placement

Suggests where to put the trigger button based on your codebase structure.

3 approaches: Existing, Auto-positioned, or Custom trigger

### Framework-Specific Code

Generates proper code following best practices for your specific framework and setup

Handles SSR, TypeScript, environment variables automatically

### User Data Prefilling

Automatically detects auth systems and prefills user name/email in the widget form

Supports Supabase, Auth0, Firebase, Clerk, and custom auth

## Example Output

Here's what the AI will generate for a Next.js project:

```js
Analysis:
✓ Detected: Next.js (App Router) with TypeScript
✓ Found: "Feedback" button in app/components/Navbar.tsx
  Confidence: 85% (High)
✓ Recommendation: Use existing element

Implementation:

// app/components/IssueCapture.tsx
'use client';
import { useEffect } from 'react';
import { createClient } from '@/lib/supabase/client';

const SCRIPT_ID = 'issuecapture-widget';

type Session = { user?: { email?: string; user_metadata?: { full_name?: string } } } | null;

function toWidgetUser(session: Session) {
  if (!session?.user) return { name: '', email: '' };
  const email = session.user.email || '';
  return { name: session.user.user_metadata?.full_name || email.split('@')[0], email };
}

export default function IssueCapture() {
  useEffect(() => {
    const apiKey = process.env.NEXT_PUBLIC_ISSUECAPTURE_API_KEY;
    if (!apiKey) return;
    const supabase = createClient();
    const widget = () => (window as any).IssueCapture;

    const init = async () => {
      const { data: { session } } = await supabase.auth.getSession();
      widget()?.init({ apiKey, trigger: '#feedback-btn', user: toWidgetUser(session) });
    };

    let created = false;
    let script = document.getElementById(SCRIPT_ID) as HTMLScriptElement | null;
    if (widget()) {
      init();
    } else {
      if (!script) {
        created = true;
        script = document.createElement('script');
        script.id = SCRIPT_ID;
        script.type = 'module';
        script.src = 'https://issuecapture.com/widget.js';
        document.head.appendChild(script);
      }
      script.addEventListener('load', init, { once: true });
    }

    // Sign-in changes update the reporter without re-running init()
    const { data: { subscription } } = supabase.auth.onAuthStateChange((_event, session) => {
      widget()?.updateConfig({ user: toWidgetUser(session) });
    });

    return () => {
      subscription.unsubscribe();
      widget()?.destroy();
      if (created) script?.remove();
    };
  }, []);

  return null;
}

// app/components/Navbar.tsx: give the existing button the trigger id
<button id="feedback-btn">Feedback</button>

// app/layout.tsx
import IssueCapture from './components/IssueCapture';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        <IssueCapture />
      </body>
    </html>
  );
}

Environment Variables:
Add to .env.local:
NEXT_PUBLIC_ISSUECAPTURE_API_KEY=your_api_key_here

Testing:
1. npm run dev
2. Open http://localhost:3000
3. Click the "Feedback" button
4. Verify widget opens
```

## Faster than a manual install

~5 minutes

to a working widget on your site

Placement

AI suggests where to put the button on your site

## Ready to Install?

Get your API key and start installing with AI

[Start free](https://issuecapture.com/signup) [Manual Installation](https://issuecapture.com/docs)

---

[View this page on issuecapture.com](https://issuecapture.com/install-with-ai)
