- Receives a Nango
connectionIdfrom your frontend - Fetches a fresh GitHub access token from Nango inside the task
- Calls the GitHub API to retrieve the user’s open pull requests
- Uses Claude to summarize what’s being worked on
Prerequisites
- A Next.js project with Trigger.dev installed
- A Nango account
- An Anthropic API key
How it works
Step 1: Connect GitHub in Nango
1
Create a GitHub integration in Nango
- In your Nango dashboard, go to Integrations and click Set up new integration.
- Search for GitHub and select GitHub (User OAuth).
- Create and add a test connection
2
Add the Nango frontend SDK
Install the Nango frontend SDK in your Next.js project:The frontend SDK requires a short-lived connect session token issued by your backend. Add an API route that creates the session:Then add a connect button to your UI that fetches the token and opens the Nango OAuth flow:
app/api/nango-session/route.ts
app/page.tsx
Step 2: Create the Trigger.dev task
Install the required packages:Step 3: Create the API route
Add a route handler that receives theconnectionId from your frontend and triggers the task:
app/api/analyze-prs/route.ts
Step 4: Set environment variables
Add the following to your.env.local file:
NANGO_SECRET_KEY and ANTHROPIC_API_KEY as environment variables in your Trigger.dev project too. These are used inside the task at runtime.
Test it
1
Start your dev servers
2
Connect GitHub and trigger the task
Open your app, click Analyze my PRs, and complete the GitHub OAuth flow. The task will be triggered automatically.
3
Watch the run in Trigger.dev
Open your Trigger.dev dashboard and navigate to Runs to see the task execute. You’ll see the PR count and Claude’s summary in the output.
Your task is now fetching a fresh GitHub token from Nango, calling the GitHub API on behalf of the
user, and using Claude to summarize their open PRs. No token storage or refresh logic required.
Next steps
- Reuse the
connectionId: Once a user has connected, store theirconnectionIdand pass it in future task payloads. No need to re-authenticate. - Add retries: If the GitHub API returns a transient error, Trigger.dev retries will handle it automatically.
- Switch providers: The same pattern works for any Nango-supported API. Change
"github"to"hubspot","slack","notion", or any other provider. - Stream the analysis: Use Trigger.dev Realtime to stream Claude’s response back to your frontend as it’s generated.

