This demo walks you through integrating AuthKit into your application in under 5 minutes
Prerequisites
Before you begin, make sure you have:- A Pica account (free to sign up)
- A Pica API key from your API keys page
- A web application where you want to add AuthKit
Backend Setup
1
Step 1
Install the backend package
Install the AuthKit token generator for your backend. This package creates secure tokens that authorize users to connect integrations.2
Step 2
Set your Pica API key
Store your Pica API key as an environment variable. Never expose this key in your frontend code.3
Step 3
Create a token generation endpoint
Create an API endpoint in your backend that generates AuthKit tokens. This endpoint should be called by your frontend when a user wants to connect an integration.- Next.js App Router
- Next.js Pages Router
- Express.js
Create a file at
app/api/authkit/route.ts
:Token parameters
A unique identifier for the user, team, organization, or project that will own the connection. Examples:
userId
, teamId
, organizationId
Specifies the type of entity that owns the connection. Must be one of:
"user"
, "team"
, "organization"
, or "project"
Choose your
identityType
based on your use case:- user: Each user has their own personal connections
- team: Team members share connections
- organization: Company-wide shared connections
- project: Project-specific isolated connections
Frontend Setup
1
Step 1
Install the frontend package
Install the AuthKit client library in your frontend application.2
Step 2
Add the AuthKit button
Create a button component that opens the AuthKit modal when clicked.- React
- Vue
- JavaScript
Configuration options
URL of your backend endpoint that generates AuthKit tokens
Headers to include in the token request (e.g., authentication headers)
The name of a specific integration to open directly (e.g., “Google Sheets”, “Slack”). If provided, AuthKit will skip the integration list and open directly to that integration’s authentication flow.
Callback when a connection is successfully created. Receives the connection object as a parameter.
Callback when an error occurs. Receives the error object as a parameter.
Callback when the modal is closed (whether successful or not)
Configure visible integrations

- Toggle integrations: Enable or disable which integrations appear in your AuthKit modal
- Set OAuth credentials: For OAuth integrations, provide your own Client ID and Client Secret to use your OAuth apps
By default, integrations are not visible. You can selectively enable only the integrations your users need. For more details on managing integrations and OAuth apps, see the Management guide.
Testing your integration
Once you’ve completed the setup, test the flow:- Click your “Connect Integration” button
- The AuthKit modal should open with your enabled integrations
- Select an integration and complete the authentication
- Your
onSuccess
callback should receive the connection details
View complete demo
Check out our example Next.js app with a full AuthKit implementation