Adopture

Installation

Install and configure Adopture Next.js SDK

Installation & Configuration

Install the Adopture Next.js SDK and configure it in your project.

Package Installation

Install the SDK using your preferred package manager:

npm install @adopture/next

Create Account & Project

  1. Sign up at app.adopture.com
  2. Create a new project
  3. Copy your API key from the project settings

Environment Configuration

Add your API key to your environment variables:

.env.local
NEXT_PUBLIC_ADOPTURE_API_KEY=your_api_key_here

The NEXT_PUBLIC_ prefix is required for client-side access in Next.js applications.

TypeScript Configuration

If you're using TypeScript, the SDK provides full type safety out of the box. No additional configuration needed.

Optional Configuration

You can customize the SDK behavior with additional environment variables:

.env.local
# Required
NEXT_PUBLIC_ADOPTURE_API_KEY=your_api_key_here

# Optional configuration
NEXT_PUBLIC_ADOPTURE_DEBUG=true
NEXT_PUBLIC_ADOPTURE_BATCH_SIZE=50
NEXT_PUBLIC_ADOPTURE_FLUSH_INTERVAL=5000

Configuration Options

VariableDefaultDescription
NEXT_PUBLIC_ADOPTURE_DEBUGfalseEnable debug logging
NEXT_PUBLIC_ADOPTURE_BATCH_SIZE50Number of events to batch before sending
NEXT_PUBLIC_ADOPTURE_FLUSH_INTERVAL5000Interval (ms) to flush events

Requirements

  • Next.js: 13.0.0 or higher (App Router or Pages Router)
  • React: 16.8.0 or higher
  • Node.js: 14.0.0 or higher

Verification

After installation, you can verify the setup by checking that the package is installed:

npm list @adopture/next

Troubleshooting

Package not found

Make sure you're installing the correct package:

npm install @adopture/next

TypeScript errors

If you see TypeScript errors, ensure you have compatible versions:

npm install --save-dev typescript@latest @types/react@latest

Environment variables not loading

  1. Restart your development server after adding environment variables
  2. Ensure .env.local is in your project root
  3. Check that variables are prefixed with NEXT_PUBLIC_

Next Steps