FeaturesCMSNotion
PreviousNext

Search

Add powerful search functionality to your Notion-powered applications.

The Notion Search feature provides a comprehensive search interface that allows users to find content across your Notion-powered blog posts, documentation, or other content types. It combines a sleek UI with powerful backend search capabilities.

Installation

Install the required dependencies:

pnpm add '@kit/notion@workspace:*'

Copy and paste the following code into your project.

components/ui/search-dialog.tsx
'use client';

import { cn, debounce } from '@kit/shared';
import { Badge } from '@kit/ui/badge';
import { Button } from '@kit/ui/button';
import {
    Command,
    CommandDialog,
    CommandEmpty,
    CommandGroup,
Get the Kit
Kit required to see the full code

Update the import paths to match your project setup.

How It Works

Backend API

The search functionality is powered by a REST API endpoint that queries your Notion content:

/api/notion/search/route.ts
import { createNotionSearchHandler } from '@kit/notion/api';
import { notionConfig } from '~/config/cms.config';
 
export const POST = createNotionSearchHandler(notionConfig);

Frontend Component

The SearchDialog component provides the user interface, handling search queries, displaying results, and navigation.

app/blog/[slug]/page.tsx
import { SearchDialog } from '@kit/notion/ui/search-dialog';
import { notionConfig } from '~/config/cms.config';
 
export function BlogPage() {
    return (
        <div className="container mx-auto py-8">
            <SearchDialog
                config={notionConfig}
                contentType="posts"
                placeholder="Search blog posts..."
            />
        </div>
    );
}

Features

  • Real-time search with 300ms debouncing for optimal performance
  • Multi-field matching across titles, descriptions, and content
  • Relevance scoring with visual indicators (High/Medium/Low)
  • Match highlighting shows exactly where matches occur

User Experience

  • Keyboard shortcuts - Press ⌘B (Mac) or Ctrl+B (Windows/Linux) to open search
  • Responsive design works on all screen sizes
  • Loading states provide feedback during search
  • Empty states guide users when no results are found

Result Presentation

  • Rich previews with titles, descriptions, and match locations
  • Score badges indicate result relevance
  • Field indicators show which fields contained matches
  • Performance metrics display search processing time

API Reference

SearchDialogProps

PropTypeDefault
config*
TConfig
contentType*
keyof...
placeholder
string
className
string

How is this guide?

Last updated on 10/17/2025