🥞PancakeJS

Capabilities

Different AI hosts support different features. Pancake provides a consistent API, but some capabilities may not be available everywhere.

Feature Availability

FeatureClaude (MCP)ChatGPT (OpenAI)
View dataYesYes
ActionsYesYes
Data fetchingYesYes
Theme detectionYesYes
NavigationYesYes
AI messagingYesYes
State persistenceYesVaries
Display modeVariesYes

Feature availability may vary by host version and configuration.

Checking Capabilities

Use the useHost hook to check available features:

import { useHost } from '@pancake-apps/web';

function MyView() {
  const host = useHost();

  return (
    <div>
      <p>Theme: {host.theme}</p>
      <p>Display mode: {host.displayMode}</p>
    </div>
  );
}

Graceful Degradation

Design your views to work even when features aren't available:

Conditional Rendering

function ViewWithOptions() {
  const host = useHost();

  return (
    <div>
      <MainContent />

      {/* Only show if messaging works */}
      <button onClick={() => say('Help me')}>
        Ask AI
      </button>
    </div>
  );
}

Alternative UI

function AdaptiveButton() {
  const { say } = useNavigation();

  // Messaging works in both hosts, so this is safe
  return (
    <button onClick={() => say('Show me more options')}>
      Get More Options
    </button>
  );
}

Theme Support

Always support both themes:

import { useTheme } from '@pancake-apps/web';

function ThemedView() {
  const theme = useTheme();

  return (
    <div
      style={{
        background: theme === 'dark' ? '#1a1a1a' : '#ffffff',
        color: theme === 'dark' ? '#ffffff' : '#000000',
      }}
    >
      {/* content */}
    </div>
  );
}

Display Mode

Adapt to how the view is displayed:

import { useDisplayMode } from '@pancake-apps/web';

function ResponsiveView() {
  const mode = useDisplayMode();

  return (
    <div
      style={{
        padding: mode === 'embedded' ? '1rem' : '2rem',
        maxWidth: mode === 'standalone' ? '1200px' : '100%',
      }}
    >
      {/* content */}
    </div>
  );
}

Best Practices

  1. Test in both hosts: Verify your view works in Claude and ChatGPT
  2. Always provide fallbacks: Don't break if a feature is missing
  3. Respect theme: Always support light and dark modes
  4. Handle errors: Wrap async operations in try/catch

Next Steps

On this page