Skip to main content

Overview

Add your Invent AI assistant to any Remix application. Perfect for full-stack React applications with nested routing and progressive enhancement.

Installation

1

Create Assistant Component

2

Add to Root

3

Configure Environment

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 Remix loaders for secure hash generation:

Using Resource Routes

Create a resource route for dynamic user data:
Then fetch in a component:

Integration with Remix Auth

Nested Routes with Context

Pass route-specific context:

TypeScript Support

Add type declarations:

Using with Sessions

Tips for Remix

Server Loaders

Use loaders for secure hash generation

Progressive Enhancement

Works without JavaScript enabled

Nested Routes

Integrate with nested routing

Type Safety

Full TypeScript support

Troubleshooting

Solutions:
  • Add check if script already exists
  • Use proper cleanup in useEffect
  • Ensure component only renders once
  • Check for duplicate components in tree
Solutions:
  • Ensure data is available on both server and client
  • Check that loader data is serializable
  • Verify useEffect cleanup
  • Test with JavaScript disabled
Solutions:
  • Restart dev server after adding variables
  • Don’t prefix server-only variables
  • Never expose secret key to client
  • Check loader returns correct data

Best Practices

  • Always use loaders for server-side operations
  • Keep secret keys server-side only
  • Leverage Remix’s built-in session management
  • Use resource routes for dynamic data
  • Test with progressive enhancement in mind