Skip to main content

Overview

The Notion client module exports a pre-configured singleton instance of the official Notion SDK client. This client is authenticated using the NOTION_TOKEN environment variable and is used by all other Notion integration modules.

Module Export

notion

The default export is a configured Client instance from @notionhq/client.
import notion from './notion-client';

Implementation

import { Client } from "@notionhq/client";
import "dotenv/config";

// Create the Notion client
const notion = new Client({
  auth: process.env.NOTION_TOKEN,
});

export default notion;

Configuration

NOTION_TOKEN
string
required
Notion API integration token. Set this environment variable before using the client.Get your token from: https://www.notion.so/my-integrations

Usage

All Notion API operations in this codebase use this shared client instance:
import notion from '@lib/notion-client';

// Query a database
const response = await notion.databases.retrieve({ 
  database_id: databaseId 
});

// Retrieve a page
const page = await notion.pages.retrieve({ 
  page_id: pageId 
});

// List block children
const blocks = await notion.blocks.children.list({
  block_id: blockId,
  page_size: 100,
});

Source Reference

File: src/lib/notion-client.ts Dependencies:
  • @notionhq/client - Official Notion JavaScript SDK
  • dotenv/config - Environment variable loading

Build docs developers (and LLMs) love