Add email, calendar, and contacts to your app in minutes. Just a few lines of code. No token management. Works with your existing auth.
Traditional email integration means weeks of OAuth implementation, token refresh logic, security reviews, and edge case handling. With Nylas Connect, it’s three lines of code.
This quickstart will walk you through integrating Nylas Connect with your existing identity provider (IDP). You’ll authenticate users through your IDP, connect their email accounts, and make API calls using your IDP tokens—no separate Nylas authentication or complex token management required.
Prerequisites
Section titled “Prerequisites”Before you begin, make sure you have:
- Nylas Developer Account: Sign up here if you don’t have one
- Identity Provider Account: Auth0, Clerk, Google Identity, WorkOS, or any IDP with JWKS support
- Node.js or Browser Environment: For running the examples
1. Configure your identity provider
Section titled “1. Configure your identity provider”First, set up your identity provider. We’ll use Auth0 for this example:
- Create an application in your Auth0 Dashboard
- Configure these settings:
- Allowed Callback URLs:
http://localhost:3000 - Allowed Web Origins:
http://localhost:3000
- Allowed Callback URLs:
- Save your Domain and Client ID
2. Configure Nylas Dashboard
Section titled “2. Configure Nylas Dashboard”Configure IDP settings in your Nylas Dashboard:
- Go to Dashboard → Hosted Authentication → Identity Providers
- Add these values:
- Allowed Origins:
http://localhost:3000 - Callback URIs:
http://localhost:3000
- Allowed Origins:
3. Install packages
Section titled “3. Install packages”Install the required packages:
npm install @nylas/connect @auth0/auth0-spa-jspnpm add @nylas/connect @auth0/auth0-spa-js4. Initialize and authenticate
Section titled “4. Initialize and authenticate”Create your authentication setup:
import { NylasConnect } from "@nylas/connect";import { Auth0Client } from "@auth0/auth0-spa-js";
// Initialize Auth0const auth0 = new Auth0Client({ domain: "<AUTH0_DOMAIN>", clientId: "<AUTH0_CLIENT_ID>", authorizationParams: { redirect_uri: window.location.origin }});
// Initialize Nylas Connect with Auth0 tokenconst nylasConnect = new NylasConnect({ clientId: "<NYLAS_CLIENT_ID>", redirectUri: window.location.origin + "/callback", identityProviderToken: async () => { return await auth0.getTokenSilently(); }});
// Login with Auth0await auth0.loginWithPopup();
// Connect email accountconst result = await nylasConnect.connect({ method: "popup" });console.log("Email connected:", result.grantInfo?.email);import { NylasConnect } from "@nylas/connect";import { Auth0Client } from "@auth0/auth0-spa-js";
// Initialize Auth0const auth0 = new Auth0Client({ domain: "<AUTH0_DOMAIN>", clientId: "<AUTH0_CLIENT_ID>", authorizationParams: { redirect_uri: window.location.origin }});
// Initialize Nylas Connect with Auth0 tokenconst nylasConnect = new NylasConnect({ clientId: "<NYLAS_CLIENT_ID>", redirectUri: window.location.origin + "/callback", identityProviderToken: async () => { return await auth0.getTokenSilently(); }});
// Login with Auth0await auth0.loginWithPopup();
// Connect email accountconst result = await nylasConnect.connect({ method: "popup" });console.log("Email connected:", result.grantInfo?.email);Replace the placeholder values:
<AUTH0_DOMAIN>- Your Auth0 domain (e.g.,your-app.us.auth0.com)<AUTH0_CLIENT_ID>- Your Auth0 Client ID<NYLAS_CLIENT_ID>- Your Nylas application’s Client ID from the dashboard
5. Make API calls with your IDP token
Section titled “5. Make API calls with your IDP token”Once authenticated, make Nylas API calls using your IDP token. One user identity. One token. Access to everything:
// Get the IDP tokenconst token = await auth0.getTokenSilently();
// Call Nylas APIconst response = await fetch( 'https://api.us.nylas.com/v3/grants/me/messages?limit=5', { headers: { 'Authorization': `Bearer ${token}` } });
const messages = await response.json();console.log("Latest messages:", messages.data);// Get the IDP tokenconst token = await auth0.getTokenSilently();
// Call Nylas APIconst response = await fetch( 'https://api.us.nylas.com/v3/grants/me/messages?limit=5', { headers: { 'Authorization': `Bearer ${token}` } });
const messages = await response.json();console.log("Latest messages:", messages.data);# Get your IDP token and user ID, then:curl --request GET \ --url 'https://api.us.nylas.com/v3/grants/me/messages?limit=5' \ --header 'Authorization: Bearer <IDP_TOKEN>' \ --header 'X-Nylas-External-User-Id: <USER_ID>'6. Check connection status
Section titled “6. Check connection status”Verify that the email account is connected:
const status = await nylasConnect.getConnectionStatus();console.log("Connection status:", status);
const session = await nylasConnect.getSession();if (session?.grantInfo) { console.log("Connected as:", session.grantInfo.email); console.log("Provider:", session.grantInfo.provider);}const status = await nylasConnect.getConnectionStatus();console.log("Connection status:", status);
const session = await nylasConnect.getSession();if (session?.grantInfo) { console.log("Connected as:", session.grantInfo.email); console.log("Provider:", session.grantInfo.provider);}What You Just Unlocked
Section titled “What You Just Unlocked”Your IDP user is now connected to their inbox. You can call Nylas APIs using your existing auth token to access:
📧 Email Integration
Section titled “📧 Email Integration”Read, send, and search messages. Full inbox access across Gmail, Outlook, Yahoo, and more. Build features like:
- Inbox management and threading
- Smart search and filtering
- Draft handling and attachments
- Rich text and HTML email composition
📅 Calendar Access
Section titled “📅 Calendar Access”Schedule, modify, and sync events. Works with Google Calendar, Outlook, iCloud, and all major providers:
- Create and manage events
- Handle availability and scheduling
- Sync across multiple calendars
- Manage recurring events and reminders
👥 Contact Management
Section titled “👥 Contact Management”Unified contact lists from all email providers. One API for everything:
- Access contacts across providers
- Create and update contact information
- Search and filter contacts
- Manage contact groups
🤖 Meeting Intelligence
Section titled “🤖 Meeting Intelligence”AI-powered transcription, summaries, action items, and insights from every meeting:
- Automatic meeting transcription
- AI-generated summaries and action items
- Speaker identification and analytics
- Searchable meeting archives
Using React?
Section titled “Using React?”If you’re building a React application, use the @nylas/react library for a better developer experience:
import { useNylasConnect } from '@nylas/react/connect';import { useAuth0 } from '@auth0/auth0-react';
function MyComponent() { const { getAccessTokenSilently } = useAuth0();
const { isConnected, connect } = useNylasConnect({ clientId: "<NYLAS_CLIENT_ID>", redirectUri: window.location.origin + "/callback", identityProviderToken: async () => { return await getAccessTokenSilently(); } });
return ( <button onClick={() => connect({ method: 'popup' })}> Connect Email </button> );}See the React IDP integration guide for complete React examples.
Next steps
Section titled “Next steps”🎉 Congratulations! You’ve just integrated email, calendar, and contacts into your app without writing a single OAuth flow or token refresh handler.
Dive Deeper
Section titled “Dive Deeper”- Full IDP Integration Guide - Detailed guides for Auth0, Clerk, Google, WorkOS, and custom IDPs
- NylasConnect Class Reference - Complete API reference and configuration options
- React Integration - Using Nylas Connect in React applications
Start Building Features
Section titled “Start Building Features”- Email API - Work with messages, threads, and attachments
- Calendar API - Schedule and manage events
- Contacts API - Access and manage contacts
Get Help and Connect
Section titled “Get Help and Connect”- Join our Developer Community - Ask questions and share what you’re building
- View Live Demos - See working examples and sample code
- API Reference - Complete API documentation