nvreact
@niivue/nvreact puts NiiVue viewers in a React app. It creates the
canvas, attaches the viewer, resizes it with the page and cleans up when the
component goes away, so you only describe what to show.
Install
npm install @niivue/nvreact@next @niivue/niivue@nextpnpm add @niivue/nvreact@next @niivue/niivue@nextyarn add @niivue/nvreact@next @niivue/niivue@nextbun add @niivue/nvreact@next @niivue/niivue@nextYou install NiiVue alongside the bindings, and your app needs React 19.
Your first viewer
import { NvViewer } from '@niivue/nvreact'
export function Brain() { return ( <NvViewer volumes={[{ url: '/volumes/mni152.nii.gz' }]} style={{ height: 500 }} /> )}The viewer fills the element it is given, so give it a height.
Which part do you need?
- One viewer on a page: the
NvViewercomponent. See One viewer. - Several viewers in a grid, optionally moving together: a scene. See Several viewers.
- Anything else NiiVue can do: a scene hands you the NiiVue instance behind each viewer, and every NiiVue guide applies to it. See Using NiiVue directly.