This directory contains examples of how to use the Nylas Node.js SDK to interact with the Nylas API.
- Grants - Examples of how to fetch, list, sort, and filter grants (authenticated connections to email/calendar providers).
- Notetakers - Examples of how to use the Nylas Notetakers API to invite a Notetaker bot to meetings, get recordings and transcripts, and more.
- Messages - Examples of how to use the Nylas Messages API to list, find, send, update messages, and work with new features like tracking options and raw MIME data.
- Folders - Examples of how to use the Nylas Folders API, including the new
singleLevelparameter for Microsoft accounts. - Calendars - Examples of how to use the Nylas Calendar API to create and manage calendar events with Notetaker integration.
- Cloudflare Vite Calendars - Modern Cloudflare Workers example using Vite for building a calendar event manager. Showcases listing and creating events with a beautiful web interface.
- Edge Environment - Standard Cloudflare Workers example for sending email attachments. Demonstrates file upload handling and email sending on the edge.
- AWS Lambda Attachments - AWS Lambda example for sending email attachments using the Nylas SDK. Demonstrates how to handle multiple file uploads (including 2+ attachments over 3MB total) without Lambda freezing. Includes interactive setup CLI and Serverless Framework deployment.
- ESM Only - Example of using the SDK with ES Modules
- CJS Only - Example of using the SDK with CommonJS
To run the Node.js examples, you'll need to:
-
Install dependencies:
cd examples npm install -
Copy the
.env.examplefile to.envand fill in your API key:cp .env.example .env # Edit .env with your editor and add your API key -
Set up the required environment variables in the
.envfile:NYLAS_API_KEY- Your Nylas API keyNYLAS_API_URI(optional) - The Nylas API server URI (defaults to "https://api.us.nylas.com")- Additional environment variables specific to each example
-
Run the example:
# Using ts-node npx ts-node grants/grants.ts npx ts-node notetakers/notetaker.ts npx ts-node calendars/event_with_notetaker.ts npx ts-node messages/messages.ts # Or using npm scripts npm run grants npm run notetakers npm run calendars npm run messages # Or if you compiled the examples npm run build node dist/grants/grants.js node dist/notetakers/notetaker.js node dist/calendars/event_with_notetaker.js node dist/messages/messages.js
The Cloudflare Workers examples are self-contained and have their own setup:
-
Navigate to the example directory:
cd examples/cloudflare-vite-calendars # or cd examples/edge-environment
-
Install dependencies:
npm install
-
Set up environment variables (see each example's README for details):
cp .dev.vars.example .dev.vars # Edit .dev.vars with your Nylas credentials -
Run the development server:
npm run dev
-
Deploy to Cloudflare (optional):
npm run deploy
Each Cloudflare example has its own comprehensive README with detailed instructions.
The AWS Lambda example is self-contained and has its own setup:
-
Navigate to the example directory:
cd examples/aws-lambda -
Run the interactive setup:
npm run setup
This will guide you through:
- Prerequisites checking
- Nylas credentials configuration
- AWS credentials setup
- Environment variable configuration
- Optional immediate deployment
-
Or set up manually:
npm install # Create .env file with your Nylas credentials # Configure AWS credentials npm run deploy
-
Test the deployed function:
- Visit the API Gateway URL displayed after deployment
- Upload multiple files and send emails
- Test with files totaling over 3MB to verify the bug fix
The AWS Lambda example includes a comprehensive README with detailed instructions and troubleshooting.
For more information, see the Nylas API Documentation.