Mantine NextJS + Fumadocs

Docs

Menu

API

Built-in API routes: search, GitHub releases and version

This starter kit provides a simple API for managing the state of the application. The API is designed to be easy to use and understand, while also being powerful enough to handle complex use cases.

Search API

The full-text search is powered by Orama through fumadocs-core/search/server: at startup the route builds an in-memory index from the docs content source — no separate indexing step, no extra build command.

The whole route is two lines:

app/api/search/route.ts

export const { GET } = createFromSource(source, {
  language: config.search.language,
});

You can try the API url here

Default route

The default URL is exposed at https://your-site.com/api/search?query=....

Client side

The search UI is a Mantine Spotlight fed by the headless useDocsSearch hook — open it with ⌘K (or /). See components/docs/DocsSearch.tsx.

components/docs/DocsSearch.tsx

const { search, setSearch, query } = useDocsSearch({ type: 'fetch' });

Static export

If you deploy as a fully static site (output: 'export'), switch the route to staticGET and the client hook to type: 'static' — the index is then exported as a static file and queried in the browser:

app/api/search/route.ts

export const { staticGET: GET } = createFromSource(source);
export const revalidate = false;

Config

The search language can be changed in the config/index.ts file:

config/index.ts

  /**
   * Search configuration (Orama via fumadocs-core)
   * @see /app/api/search/route.ts
   */
  search: {
    language: 'english',
  },

GitHub Release API

The GitHub Release API is a simple API that allows you to get the latest release of a GitHub repository. It is designed to be easy to use and understand, while also being powerful enough to handle complex use cases.

Have a look at the Release Notes page to see it in action.

Default route

The default URL is exposed at https://your-site.com/api/github-releases.

Config

You may configure the API in the config/index.ts file:

config/index.ts

  /**
   * GitHub API configuration
   * @see https://docs.github.com/en/rest/reference/repos#releases
   *
   * The GitHub API token is optional for rate limiting.
   * If you want to use it, create a personal access token with the `repo` scope.
   *
   * This information is used to fetch the releases from the GitHub API.
   */
  gitHub: {
    repo: 'gfazioli/next-app-fumadocs-template',
    apiUrl: 'https://api.github.com',
    releasesUrl: 'https://api.github.com/repos/gfazioli/next-app-fumadocs-template/releases',
  },

  /**
   * Release notes configuration
   * This is used to link the release notes in the app.
   */
  releaseNotes: {
    url: 'https://github.com/gfazioli/next-app-fumadocs-template/releases',
    maxReleases: 10,
  },

Rate limiting

The GitHub API has a rate limit of 60 requests per hour for unauthenticated requests. If you want to increase the rate limit, you can create a personal access token with the repo scope and add it to the GITHUB_TOKEN environment variable.

You have to update app/api/github-releases/route.ts

    const response = await fetch(
      `${config.gitHub.releasesUrl}?per_page=${config.releaseNotes.maxReleases}`,
      {
        headers: {
          Accept: 'application/vnd.github+json',
          // Authorization: `Bearer ${process.env.GITHUB_TOKEN}`, // Optional for rate limit
        },
      }
    );

Version API

The /api/version route returns the current version of the application, read from package.json:

{ "version": "0.1.0" }