Getting Started with webMCP React Components
Step-by-step guide to integrating webMCP's AI-optimized React components into your applications for instant token savings.
React developers can now leverage webMCP optimization directly in their components. Our new @webmcp/react package provides AI-optimized form components that reduce token usage by up to 67.6% automatically.
Quick Installation
npm install @webmcp/react @webmcp/coreBasic Usage
Here's how to create an AI-optimized contact form in just a few lines:
import { WebMCPForm, WebMCPInput, WebMCPButton } from '@webmcp/react';
function ContactForm() {
return (
<WebMCPForm goalDescription="Collect contact information">
<WebMCPInput name="name" aiSuggestions={true} />
<WebMCPInput name="email" type="email" aiSuggestions={true} />
<WebMCPButton type="submit">Submit</WebMCPButton>
</WebMCPForm>
);
}Available Components
WebMCPForm
AI-optimized form wrapper with 67.6% token reduction and real-time analytics.
WebMCPInput
Smart input with AI suggestions for email, name, and phone fields.
WebMCPButton
Semantic button with role mapping for AI agent interactions.
WebMCPAnalytics
Real-time metrics dashboard showing token savings and cost tracking.
Advanced Example with Analytics
import { WebMCPForm, WebMCPInput, WebMCPButton, WebMCPAnalytics, useWebMCP } from '@webmcp/react';
function AdvancedForm() {
const { analytics, isOptimizing } = useWebMCP({
targetModel: 'gpt-4o',
compressionLevel: 'advanced'
});
return (
<div>
<WebMCPForm goalDescription="User registration with analytics">
<WebMCPInput
name="firstName"
webmcpRole="input.name.first"
aiSuggestions={true}
validation="required"
/>
<WebMCPInput
name="email"
type="email"
webmcpRole="input.email"
aiSuggestions={true}
/>
<WebMCPButton
type="submit"
disabled={isOptimizing}
webmcpRole="action.submit"
>
{isOptimizing ? 'Optimizing...' : 'Register'}
</WebMCPButton>
</WebMCPForm>
<WebMCPAnalytics />
</div>
);
}Key Benefits
Next Steps
Ready to integrate webMCP React components into your application? Check out our complete documentation and interactive examples to get started.
🚀 Try it Now
Experience the components in action with our interactive playground and live demos.