New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

chatjs-hooks

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chatjs-hooks

React hooks for ChatGPT widgets

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

chatjs-hooks

React hooks for ChatGPT widgets.

Installation

npm install chatjs-hooks

Usage

useWidgetProps

Get data passed from your MCP tool to your React widget:

import React from 'react';
import { useWidgetProps } from 'chatjs-hooks';

export default function MyWidget() {
  const { message, count } = useWidgetProps();
  
  return (
    <div>
      <h1>{message}</h1>
      <p>Count: {count}</p>
    </div>
  );
}

useWidgetState

Manage stateful data that persists in ChatGPT:

import React from 'react';
import { useWidgetState } from 'chatjs-hooks';

export default function Counter() {
  const [state, setState] = useWidgetState({ count: 0 });
  
  return (
    <button onClick={() => setState({ count: state.count + 1 })}>
      Count: {state?.count || 0}
    </button>
  );
}

useOpenAiGlobal

Access ChatGPT global values like theme, display mode, etc:

import React from 'react';
import { useOpenAiGlobal } from 'chatjs-hooks';

export default function ThemedWidget() {
  const theme = useOpenAiGlobal('theme');
  const displayMode = useOpenAiGlobal('displayMode');
  
  return (
    <div className={`theme-${theme} mode-${displayMode}`}>
      <h1>Themed Widget</h1>
    </div>
  );
}

TypeScript

This package is written in TypeScript and includes type definitions.

import { useWidgetProps } from 'chatjs-hooks';

interface MyWidgetProps {
  message: string;
  count: number;
}

export default function MyWidget() {
  const { message, count } = useWidgetProps<MyWidgetProps>();
  // message and count are properly typed!
}

License

MIT

Keywords

chatgpt

FAQs

Package last updated on 15 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts