code for a connection_id and lists their repositories through the Unified API.
Prerequisites
- Node.js 18+ installed.
- In the BundleUp dashboard, complete steps 1 to 3 of the Quickstart:
- a GitHub integration with the identifier
github, http://localhost:3000/callbackregistered under Auth → Redirect URIs,- an API key, and your Client ID from the Auth page.
- a GitHub integration with the identifier
Step 1: Create a new Next.js app
If you don’t already have a Next.js project, start by creating one. BundleUp works with both the App Router and Pages Router, but this guide uses the App Router. Run one of the following commands to scaffold a new app:Step 2: Install @bundleup/sdk
Next, install the official BundleUp SDK. This SDK is used server-side to make authenticated requests to third-party APIs using a connection_id.
Step 3: Configure environment variables
BundleUp uses two types of credentials:- A server-side API key for making API requests
- A client-safe Client ID for starting the authorization flow
.env.local file in your project root and add the following:
.env.local
Step 4: Create the authorization link
In this step, you’ll create a simple page that sends the user to BundleUp’s authorization endpoint. This URL:- Identifies your app (
client_id) - Specifies which integration to connect (
integration_id) - Defines where the user should be redirected after authorization (
redirect_uri)
app/page.tsx
Step 5: Handle the callback and fetch data
After the user authorizes the integration, BundleUp redirects them back to your app with a one-timecode.
The code is not the connection. Your server exchanges it, using your API key, for a connection_id. The code expires after 5 minutes and can only be used once.
The connection_id represents:
- A specific user
- A specific integration
- Securely stored credentials managed by BundleUp
connection_id is stable and reusable. You should store it and reuse it for future requests instead of re-authorizing the user.
Create a callback page (for example, app/callback/page.tsx), exchange the code, and use the SDK to fetch data:
app/callback/page.tsx
redirectUri must be exactly the same value you used to start the flow. BundleUp rejects the exchange otherwise.- BundleUp handles authentication, token refresh, and API differences
- You make a single, normalized API call
Step 6: Run your application
Start your Next.js development server:http://localhost:3000 and click “Connect GitHub”. You’ll be redirected to GitHub to authorize the connection. After authorization, you’ll be redirected back and can fetch your repositories.
Next steps
- Store the
connection_idagainst the signed-in user in your database, and reuse it. Don’t send the user through the flow again. - Pass a
statevalue when you build the authorization URL and check it in the callback, to protect against CSRF. See Connecting user accounts. - Pass an
external_id(your user ID) so you can find connections by user later. - Call the provider directly through the Proxy when you need something the Unified API doesn’t cover.
- See the full JavaScript SDK reference.

