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/nextCreate Account & Project
- Sign up at app.adopture.com
- Create a new project
- Copy your API key from the project settings
Environment Configuration
Add your API key to your environment variables:
NEXT_PUBLIC_ADOPTURE_API_KEY=your_api_key_hereThe 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:
# 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=5000Configuration Options
| Variable | Default | Description |
|---|---|---|
NEXT_PUBLIC_ADOPTURE_DEBUG | false | Enable debug logging |
NEXT_PUBLIC_ADOPTURE_BATCH_SIZE | 50 | Number of events to batch before sending |
NEXT_PUBLIC_ADOPTURE_FLUSH_INTERVAL | 5000 | Interval (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/nextTroubleshooting
Package not found
Make sure you're installing the correct package:
npm install @adopture/nextTypeScript errors
If you see TypeScript errors, ensure you have compatible versions:
npm install --save-dev typescript@latest @types/react@latestEnvironment variables not loading
- Restart your development server after adding environment variables
- Ensure
.env.localis in your project root - Check that variables are prefixed with
NEXT_PUBLIC_