Overview
Connect your Next.js application to Kubiks using the Vercel OpenTelemetry SDK with HTTP exporters. This setup works for any deployment platform (not just Vercel) and provides complete observability for your app.Installation
Install the required OpenTelemetry packages:Environment Variables
Add these environment variables to your deployment configuration:.env.local
Configuration
Create aninstrumentation.ts file in your project root (same level as app/ or pages/):
instrumentation.ts
Next.js automatically loads 
instrumentation.ts when the application starts. No additional imports needed!Environment-Specific Configuration
Set environment variables based on your deployment platform:- Vercel
- Docker
- Railway / Render
- Self-Hosted
Add environment variables in your Vercel project settings:
- Go to Settings → Environment Variables
- Add KUBIKS_API_KEYwith your API key
- Add OTEL_EXPORTER_OTLP_ENDPOINTwith valuehttps://ingest.kubiks.app
- Add OTEL_SERVICE_NAMEwith your app name
- Deploy your application
Get Your API Key
1
Navigate to Connect Page
Go to kubiks.app/connect in your dashboard
2
Create API Key
Click Create API Key in the OpenTelemetry Ingestion section
3
Copy the Key
Copy the generated API key and add it to your environment variables
Verify Setup
Once configured, your Next.js app will automatically send traces and logs to Kubiks. To verify:- Start your development server or deploy your app
- Make some requests to your application
- Check your Kubiks dashboard for traces and logs
Traces appear in real-time. If you don’t see data after a few seconds, check your API key and endpoint configuration.
What Gets Tracked
The@vercel/otel package automatically instruments:
HTTP Requests
HTTP Requests
- All incoming HTTP requests
- Request/response headers
- Status codes and response times
- URL paths and query parameters
Next.js Internals
Next.js Internals
- Server-side rendering (SSR)
- API routes
- Server components
- Middleware
- Static generation
External Calls
External Calls
- fetch()calls to external APIs
- Database queries (when instrumented)
- Third-party service calls
Performance Metrics
Performance Metrics
- Request duration
- Time to first byte (TTFB)
- Server-side rendering time
- API response times
Instrument Your Dependencies
Enhance observability by adding Kubiks OpenTelemetry SDKs for popular frameworks:Drizzle ORM
Trace all database queries and transactions
Better Auth
Monitor authentication flows and sessions
Resend
Track email delivery and operations
Upstash QStash
Monitor message queue operations
Autumn Billing
Trace billing and payment flows
View All Integrations
Explore all available SDKs
Troubleshooting
No traces appearing
No traces appearing
Check these common issues:
- Verify KUBIKS_API_KEYis set correctly
- Confirm OTEL_EXPORTER_OTLP_ENDPOINTishttps://ingest.kubiks.app
- Ensure instrumentationHook: trueis innext.config.ts
- Check that instrumentation.tsis in your project root
- Restart your development server after config changes
instrumentation.ts not loading
instrumentation.ts not loading
Make sure:
- File is named exactly instrumentation.ts(or.js)
- File is in project root (same level as app/orpages/)
- experimental.instrumentationHookis enabled in Next.js config
- You’re using Next.js 13.2 or later
Invalid API key errors
Invalid API key errors
- Double-check your API key from kubiks.app/connect
- Ensure no extra spaces or quotes in your .env.local
- Verify environment variables are loaded (check process.env.KUBIKS_API_KEY)
- For production, confirm variables are set in your deployment platform
Only seeing some traces
Only seeing some traces
The SDK uses sampling by default. To see all traces in development:
instrumentation.ts