To create a hiddify client in React, you'll need to include the hiddify library and use the HidifyClient component. Here's a step-by-step example:
{
"dependencies": {
"hiddify": "^latest"
}
}
- Import the necessary modules:
import "react/hidify/client.hc";
import { HidifyClient } from "react/hidify/client";
- Create a client instance:
import { HidifyClient } from "react/hidify/client";
const client = HidifyClient.create({
id: 'my-id',
serverId: 'localhost:3',
state: () => () => ({
show: false,
...new({ state: {} })
})
});
// Or, if you need to handle server-side requests, you can set up a custom client
// like:
const customClient = {
type: HidifyClient,
create: function({ id, ... }) {
return (client = this.create({ id }) as HidifyClient) {
if (client) {
client?.handleServer({ id });
}
};
}
};
const clientWithServer = customClient({ id: 'my-id' });
- Use the client in your component:
function Home() {
return (
<HidifyClient id={cid} />
{/* other components */}
);
}
This setup allows you to create a hiddify client for your React application, which can handle both client and server requests.




