Skip to content

Commit 4a6ab76

Browse files
authored
fix: readme update (#193)
1 parent 608fb09 commit 4a6ab76

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

docs/rules/ssr/ssr-no-unsupported-node-api.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,17 @@ if (import.meta.env.SSR) {
2727
}
2828
```
2929
30-
### Example of **incorrect** code:
30+
### Example of **correct** code:
3131
3232
```js
33-
// Do not use Node APIs
33+
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+
}
3443
```

0 commit comments

Comments
 (0)