Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.firstflow.app/llms.txt

Use this file to discover all available pages before exploring further.

Requirements

SDKRequirements
@firstflow/reactReact 18+, TypeScript 5+ (optional but recommended)
@firstflow/nextjsNext.js 14+ (App Router), React 18+
@firstflow/react-nativeReact Native 0.70+, React 18+

React

npm install @firstflow/react
Peer dependencies (install if not already present):
npm install react react-dom

Next.js

npm install @firstflow/nextjs
The Next.js SDK re-exports everything from @firstflow/react and adds server utilities (getFirstflowConfig) for SSR config prefetching.

React Native

npm install @firstflow/react-native
npm install @react-native-async-storage/async-storage
AsyncStorage is required for frequency tracking on mobile. Without it, frequency limits fall back to in-memory state (reset on app restart).

Environment variables

VITE_FIRSTFLOW_AGENT_ID=your-agent-id
VITE_FIRSTFLOW_API_KEY=your-api-key
The SDK automatically selects the API URL:
EnvironmentDefault URL
Development (localhost)http://localhost:3002
Productionhttps://api.firstflow.app
Override with the env vars above for staging or self-hosted deployments.

TypeScript

The SDK ships its own type definitions. No @types/* packages required. If you encounter type errors after installation, add to tsconfig.json:
{
  "compilerOptions": {
    "skipLibCheck": true,
    "moduleResolution": "bundler"
  }
}

Bundler compatibility

The SDK uses the exports field in package.json. Supported bundlers:
  • Vite 3+
  • Webpack 5+
  • Rollup 3+
  • Metro 0.60+ (React Native)
  • Turbopack (Next.js 13.5+)

Verify

import { FirstflowProvider, useFirstflow } from "@firstflow/react";
// Types resolve immediately — no import errors means installation succeeded

Troubleshooting installation

Your bundler may not resolve the exports field. Ensure you’re on Webpack 5, Vite 3+, or Metro 0.60+. For older setups, use the CommonJS build: import { FirstflowProvider } from "@firstflow/react/cjs".
Set skipLibCheck: true in tsconfig.json. Ensure @types/react is installed.
Add to metro.config.js:
const path = require("path");
config.resolver.extraNodeModules = {
  ...config.resolver.extraNodeModules,
  "@firstflow/react-native": path.resolve(
    __dirname,
    "node_modules/@firstflow/react-native"
  ),
};