We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 608fb09 commit 4a6ab76Copy full SHA for 4a6ab76
docs/rules/ssr/ssr-no-unsupported-node-api.md
@@ -27,8 +27,17 @@ if (import.meta.env.SSR) {
27
}
28
```
29
30
-### Example of **incorrect** code:
+### Example of **correct** code:
31
32
```js
33
-// Do not use Node APIs
+if (!import.meta.env.SSR) {
34
+ // Client-side code: Safe to use Node APIs here if necessary
35
+ const fs = require('fs'); // Example of a Node API (e.g., for file operations)
36
+
37
+ // Your Node API logic goes here, which will only run on the client-side
38
+ fs.writeFileSync('file.txt', 'client-side data');
39
+} else {
40
+ // SSR : Do not use Node APIs here
41
+ console.log('Running in SSR context, Node APIs are not available.');
42
+}
43
0 commit comments