npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fastapps

v1.1.2

Published

React hooks for FastApps - The fastest way to build Apps in ChatGPT

Readme

fastapps (React Hooks)

React hooks for building interactive ChatGPT widgets with the FastApps framework.

Installation

npm install fastapps

Usage

useWidgetProps

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

import React from 'react';
import { useWidgetProps } from 'fastapps';

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

useWidgetState

Manage stateful data that persists across ChatGPT sessions:

import React from 'react';
import { useWidgetState } from 'fastapps';

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 environment information like theme, display mode, locale, and more:

import React from 'react';
import { useOpenAiGlobal } from 'fastapps';

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

useDisplayMode

Access the current display mode (inline, pip, or fullscreen):

import React from 'react';
import { useDisplayMode } from 'fastapps';

export default function ResponsiveWidget() {
  const displayMode = useDisplayMode();
  
  return (
    <div className={`mode-${displayMode}`}>
      {displayMode === 'fullscreen' ? (
        <div>Full screen layout</div>
      ) : (
        <div>Compact layout</div>
      )}
    </div>
  );
}

useMaxHeight

Access the maximum height constraint for the widget:

import React from 'react';
import { useMaxHeight } from 'fastapps';

export default function ScrollableWidget() {
  const maxHeight = useMaxHeight();
  
  return (
    <div style={{ maxHeight: `${maxHeight}px`, overflow: 'auto' }}>
      <p>Content that respects the max height constraint</p>
      {/* More content... */}
    </div>
  );
}

Available Hooks

Core Hooks

  • useOpenAiGlobal(key) - Access any ChatGPT environment property
  • useWidgetProps<T>(defaultState?) - Access tool output data from your Python tool
  • useWidgetState<T>(defaultState) - Persistent state management that syncs with ChatGPT
  • useDisplayMode() - Get current display mode (inline/pip/fullscreen)
  • useMaxHeight() - Get maximum height constraint in pixels

Available OpenAI Globals

Use useOpenAiGlobal(key) to access:

  • theme - Light or dark mode
  • displayMode - inline, pip, or fullscreen
  • locale - User's locale (IETF BCP 47)
  • maxHeight - Layout height constraint
  • safeArea - Mobile safe area insets
  • userAgent - Device and capabilities
  • toolInput - Input parameters
  • toolOutput - Tool response data
  • toolResponseMetadata - Response metadata
  • widgetState - Current persistent state

Custom Convenience Hooks

You can easily create your own convenience hooks:

// Access tool input
export function useToolInput() {
  return useOpenAiGlobal('toolInput');
}

// Access theme
export function useTheme() {
  return useOpenAiGlobal('theme');
}

Advanced: Direct window.openai API

// Call backend tools
await window.openai.callTool('refresh_data', { city: 'NYC' });

// Send follow-up messages
await window.openai.sendFollowUpMessage({ 
  prompt: 'Tell me more' 
});

// Request display mode changes
await window.openai.requestDisplayMode({ 
  mode: 'fullscreen' 
});

// Open external links
window.openai.openExternal({ href: 'https://example.com' });

TypeScript Support

This package is written in TypeScript and includes full type definitions:

import { 
  useWidgetProps, 
  useOpenAiGlobal,
  useDisplayMode,
  useMaxHeight 
} from 'fastapps';
import type { Theme, DisplayMode, UserAgent } from 'fastapps';

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

export default function MyWidget() {
  const props = useWidgetProps<MyWidgetProps>();
  const theme = useOpenAiGlobal('theme');
  const displayMode = useDisplayMode();
  const maxHeight = useMaxHeight();
  
  // Fully typed!
  return (
    <div 
      className={`theme-${theme}`}
      style={{ maxHeight: `${maxHeight}px` }}
    >
      {props.message} (Mode: {displayMode})
    </div>
  );
}

Documentation

Full documentation available at fastapps.org

Part of FastApps Framework

This package is the React hooks component of the FastApps framework for building ChatGPT widgets.

  • Python SDK: pip install fastapps
  • React Hooks: npm install fastapps

License

MIT