@@ -122,9 +122,8 @@ type DevToolsProps = {
122122### Provider-less
123123
124124``` tsx
125- import { DevTools } from ' jotai-devtools ' ;
125+ import { DevTools } from ' ./JotaiDevTools ' ;
126126import ' jotai-devtools/styles.css' ;
127-
128127const App = () => {
129128 return (
130129 <>
@@ -139,6 +138,7 @@ const App = () => {
139138
140139``` tsx
141140import { createStore } from ' jotai' ;
141+
142142import { DevTools } from ' jotai-devtools' ;
143143import ' jotai-devtools/styles.css' ;
144144
@@ -154,6 +154,73 @@ const App = () => {
154154};
155155```
156156
157+ ## Tree-shaking
158+
159+ Jotai DevTools is currently only available in development mode. We're changing
160+ this in the future to allow it to be used in production as well.
161+
162+ Therefore, we recommend wrapping the DevTools in a conditional statement and
163+ tree-shake it out in production to avoid any accidental usage in production.
164+
165+ ### Vite
166+
167+ ``` tsx
168+ import { DevTools } from ' jotai-devtools' ;
169+ import css from ' jotai-devtools/styles.css?inline' ;
170+
171+ const JotaiDevTools = () =>
172+ process .env .NODE_ENV !== ' production' ? (
173+ <>
174+ <style >{ css } </style >
175+ <DevTools />
176+ </>
177+ ) : null ;
178+
179+ const App = () => {
180+ return (
181+ <>
182+ <JotaiDevTools />
183+ { /* your app */ }
184+ </>
185+ );
186+ };
187+ ```
188+
189+ ### NextJS
190+
191+ Create a ` DevTools.tsx ` file in your project and export the ` DevTools `
192+ component.
193+
194+ ``` tsx
195+ import ' jotai-devtools/styles.css' ;
196+ export { DevTools } from ' jotai-devtools' ;
197+ ```
198+
199+ Then, in your app, import the ` DevTools ` component conditionally.
200+
201+ ``` tsx
202+ import dynamic from " next/dynamic" ;
203+ import type { ComponentType } from " react" ;
204+ import type { DevToolsProps } from " jotai-devtools" ;
205+
206+ let DevTools: ComponentType <DevToolsProps > | null = null ;
207+
208+ if (process .env .NODE_ENV !== " production" ) {
209+ DevTools = dynamic (
210+ () => import (" ./DevTools" ).then ((mod ) => ({ default: mod .DevTools })),
211+ { ssr: false }
212+ );
213+ }
214+
215+ const App = () => {
216+ return (
217+ <>
218+ { DevTools && <DevTools />}
219+ { /* your app */ }
220+ </>
221+ );
222+ ` ` `
223+
157224## Hooks
158225
159226Detailed documentation is available on
0 commit comments