Skip to Content
🎉 Nextra 4.0 is released. dimaMachina is looking for a new job or consulting .

API

useThemeConfig hook

The useThemeConfig hook returns values of your theme configuration and is made to dynamically configure your project.

import { useThemeConfig } from 'nextra-theme-docs'
Parameters:
This function does not accept any parameters.
Returns:

A subset of your theme configuration context.

NameType
darkModeboolean
docsRepositoryBasestring
feedback.contentstring | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | ReactPortal | Iterable<ReactNode> | Promise<...> | null
feedback.labelsstring
i18n{ locale: string; name: string; }[]
lastUpdatedReactElement<Record<string, unknown>, string | JSXElementConstructor<any>>
sidebar.defaultMenuCollapseLevelnumber
sidebar.defaultOpenboolean
sidebar.toggleButtonboolean
sidebar.autoCollapseboolean | undefined
themeSwitch.darkstring
themeSwitch.lightstring
themeSwitch.systemstring
toc.floatboolean
toc.backToTopstring | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | ReactPortal | Iterable<ReactNode> | Promise<...> | null
toc.titlestring | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | ReactPortal | Iterable<ReactNode> | Promise<...> | null
toc.extraContentReactNode

useConfig hook

import { useConfig } from 'nextra-theme-docs'

The useConfig hook returns data from your current page context.

Parameters:
This function does not accept any parameters.
Returns:

An object containing the normalizePagesResult and a hideSidebar value.

NameType
normalizePagesResult.activeType"doc" | "page" | "menu"

Active type for current page, used to determine layout in theme.

normalizePagesResult.activeIndexnumber

Active index for current page, used for pagination in combination with flatDocsDirectories items.

normalizePagesResult.activeThemeContext.paginationboolean | undefined
normalizePagesResult.activeThemeContext.breadcrumbboolean | undefined
normalizePagesResult.activeThemeContext.collapsedboolean | undefined
normalizePagesResult.activeThemeContext.footerboolean | undefined
normalizePagesResult.activeThemeContext.layout"default" | "full" | undefined
normalizePagesResult.activeThemeContext.navbarboolean | undefined
normalizePagesResult.activeThemeContext.sidebarboolean | undefined
normalizePagesResult.activeThemeContext.timestampboolean | undefined
normalizePagesResult.activeThemeContext.tocboolean | undefined
normalizePagesResult.activeThemeContext.typesetting"default" | "article" | undefined
normalizePagesResult.activeMetadataFrontMatter

Parsed front matter  or exported Metadata  from page.

normalizePagesResult.activePathItem[]

Active path for current page, used for breadcrumb navigation.

normalizePagesResult.directoriesItem[]

All directories in the tree structure.

normalizePagesResult.docsDirectoriesDocsItem[]

Directories with type: 'doc' in _meta file.

normalizePagesResult.flatDocsDirectoriesDocsItem[]

Flattened directories with type: 'doc' in _meta file.

normalizePagesResult.topLevelNavbarItems(PageItem | MenuItem)[]

Navbar items, items which have type: 'page' in _meta file.

hideSidebarboolean

Whether the sidebar is shown. If false, the theme and locale switchers are displayed in the <Footer>.

Last updated on