Skip to content

nvreact

View as Markdown

@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

Terminal window
npm install @niivue/nvreact@next @niivue/niivue@next

You 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 NvViewer component. 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.