medusa-contact-logic-plugin
v1.1.2
Published
A lightweight React hook for handling contact form logic in Medusa storefronts.
Downloads
30
Readme
Medusa Contact Logic Plugin
A lightweight React hook for handling contact form logic in Medusa storefronts.
Features
- Easy integration with Medusa backend.
- Handles loading, success, and error states.
- Support for Medusa publishable keys.
- Works with both React and Next.js.
Installation
npm install medusa-contact-logic-pluginUsage
import { useContactForm } from 'medusa-contact-logic-plugin';
const MyComponent = () => {
const { status, message, handleSubmit } = useContactForm({
baseUrl: 'https://your-medusa-url.com',
publishableKey: 'pk_...', // Optional
onComplete: (data) => console.log('Form sent:', data)
});
return (
<form onSubmit={handleSubmit}>
<input name="email" type="email" required placeholder="Your Email" />
<textarea name="message" required placeholder="Your Message" />
<button type="submit" disabled={status === 'pending'}>
{status === 'pending' ? 'Sending...' : 'Send Message'}
</button>
{message && <p>{message}</p>}
</form>
);
};Props
| Prop | Type | Description |
| :--- | :--- | :--- |
| baseUrl | string | Your Medusa Backend URL. |
| publishableKey | string | (Optional) Your Medusa Publishable API Key. |
| onComplete | (data: any) => void | (Optional) Callback after successful submission. |
License
MIT
