Getting Started
Installation

Installation

Get started with Prompt My Client React in your project.

📋 Prerequisites

  • Node.js 16.8 or later
  • React 18 or higher
  • npm, yarn, or pnpm

🚀 Install

Using npm

npm install prompt-my-client-react

Using yarn

yarn add prompt-my-client-react

Using pnpm

pnpm add prompt-my-client-react

🔧 Quick Start

Option 1: Using the AIDropDown Component

import { AIDropDown } from 'prompt-my-client-react';
 
function App() {
  const [text, setText] = useState('');
 
  const handleAIResponse = (response: string) => {
    if (response) {
      setText(response);
    }
  };
 
  return (
    <div>
      <textarea 
        value={text}
        onChange={(e) => setText(e.target.value)}
        placeholder="Type your text here..."
      />
      <AIDropDown 
        text={text} 
        aiResponseCallback={handleAIResponse} 
      />
    </div>
  );
}

Option 2: Using the usePrompt Hook

import { usePrompt } from 'prompt-my-client-react';
 
function App() {
  const [text, setText] = useState('');
  
  const { generatePrompt, isLoading, error, result } = usePrompt({
    onSuccess: (response) => {
      setText(response);
    },
    onError: (error) => {
      console.error('Error:', error);
    }
  });
 
  const handleGenerate = async () => {
    await generatePrompt(text, "Make this text more professional");
  };
 
  return (
    <div>
      <textarea 
        value={text} 
        onChange={(e) => setText(e.target.value)}
        placeholder="Type your text here..." 
      />
      <button onClick={handleGenerate} disabled={isLoading}>
        {isLoading ? 'Processing...' : 'Make Professional'}
      </button>
    </div>
  );
}

📚 Next Steps

  • Check out the Demos for more usage patterns
  • Read the API Reference for complete documentation