Orama Cloud
Integrate with Orama Cloud
To begin, create an account on Orama Cloud.
REST API
REST API integration requires your docs to upload the indexes.
-
Create a new project with REST API data source on Orama Cloud dashboard.
Store your credentials in
.env.local, for example (VITE_instead ofNEXT_PUBLIC_outside Next.js):NEXT_PUBLIC_ORAMA_DATASOURCE_ID="Rest API data source ID" NEXT_PUBLIC_ORAMA_PROJECT_ID="project ID" NEXT_PUBLIC_ORAMA_API_KEY="public API key" ORAMA_PRIVATE_API_KEY="private API key" -
Pre-render a
static.jsonroute to export the search indexes on build, and sync them to Orama Cloud with a script after each build:app/static.json/route.ts import { source } from '@/lib/source'; import { toDocuments } from 'fumadocs-core/search/orama-cloud'; export const revalidate = false; export async function GET() { return Response.json(await toDocuments(source)); }scripts/sync-content.ts import * as fs from 'node:fs/promises'; import { type OramaDocument as DocumentRecord, sync } from 'fumadocs-core/search/orama-cloud'; import { OramaCloud } from '@orama/core'; const records = JSON.parse(await fs.readFile('.next/server/app/static.json.body', 'utf-8')) as DocumentRecord[]; const orama = new OramaCloud({ projectId: process.env.NEXT_PUBLIC_ORAMA_PROJECT_ID!, apiKey: process.env.ORAMA_PRIVATE_API_KEY!, }); await sync(orama, { index: process.env.NEXT_PUBLIC_ORAMA_DATASOURCE_ID!, documents: records, }); console.log(`search updated: ${records.length} records`);package.json { "scripts": { "build": "next build && node --env-file-if-exists=.env.local scripts/sync-content.ts" } }The
buildscript syncs on every build, set the same variables on your deployment platform.
Search Client
To search documents on the client side, consider:
-
Using Fumadocs UI search dialog.
-
Custom search UI using the built-in hook of Fumadocs:
import { useOramaCloudSearch } from 'fumadocs-core/search/client'; import { OramaCloud } from '@orama/core'; const orama = new OramaCloud({ projectId: process.env.NEXT_PUBLIC_ORAMA_PROJECT_ID, apiKey: process.env.NEXT_PUBLIC_ORAMA_API_KEY, }); const params = { // optional search params }; const { search, onSearchChange, isLoading, data } = useOramaCloudSearch({ client: orama, params, }); -
Use their search client directly.
Web Crawler
- Create a Crawler data source from dashboard, and configure it correctly with the "Documentation" preset.
Search Client
Same as REST API integration, but make sure to set index to crawler.
import { useOramaCloudSearch } from 'fumadocs-core/search/client';
import { OramaCloud } from '@orama/core';
const orama = new OramaCloud({
projectId: '<project id>',
apiKey: '<read only api key>',
});
const params = {
// optional search params
};
const { search, onSearchChange, isLoading, data } = useOramaCloudSearch({
index: 'crawler',
client: orama,
params,
});It's same for Fumadocs UI.
How is this guide?
Last updated on
