Skip to main content

<RecoilRoot ...props />

Provides the context in which atoms have values. Must be an ancestor of any component that uses any Recoil hooks. Multiple roots may co-exist; atoms will have distinct values within each root. If they are nested, the innermost root will completely mask any outer roots.


  • initializeState?: (MutableSnapshot => void)

<RecoilRoot>'s represent independent providers/stores of atom state. Note that caches, such as selector caches, may be shared across roots. Selector evaluations must be idempotent except for caching or logging, so this should not be a problem, but may be observable or may cause redundant queries to be cached across roots.


import {RecoilRoot} from 'recoil';
function AppRoot() {
return (
<ComponentThatUsesRecoil />