Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,36 @@ This project is based on [fhevmjs](https://github.com/zama-ai/fhevmjs) by Zama a
#### Need support?

Open an issue or Pull Request on Github! Or reach out to us on [Discord](https://discord.com/invite/FuVgxrvJMY) or Telegram.

## Using Fhenix.js in Client-Side Frameworks

Fhenix.js relies on a WebAssembly file (`tfhe_bg.wasm`) which is **client-side only**.
When using frameworks like Next.js, React (Vite), or others, this can cause errors if the WASM file is loaded during SSR (server-side rendering).

### Next.js Example
```javascript
import dynamic from 'next/dynamic';

const Token = dynamic(() => import('../components/token'), { ssr: false });

Vite + React Example
// vite.config.js
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import wasm from 'vite-plugin-wasm';
import topLevelAwait from 'vite-plugin-top-level-await';

export default defineConfig({
plugins: [wasm(), topLevelAwait(), react()],
optimizeDeps: { exclude: ['fhenixjs'] },
});

Alternative
Use the UMD build directly via a <script> tag:
<script src="https://cdn.jsdelivr.net/npm/fhenixjs@0.3.0/dist/fhenix.umd.min.js"></script>

Notes
Always use Fhenix.js on the client side for user interactions.
Avoid importing it directly in SSR code.

---