pollinations-react
v1.1.9
Published
React components and hooks for Pollinations AI
Downloads
11
Readme
pollinations-react
A simple React package for generating images using Pollinations' API.
Installation
npm install pollinations-react
Usage
Hook
The usePollinationsImage
hook allows you to generate images using Pollinations' API and use them in your React components.
import React from 'react';
import { usePollinationsImage } from 'pollinations-react';
const MyComponent = () => {
const imageUrl = usePollinationsImage('A beautiful sunset over the ocean');
return (
<div>
{imageUrl ? <img src={imageUrl} alt="Generated" /> : <p>Loading...</p>}
</div>
);
};
export default MyComponent;
Component
The PollinationsImage
component simplifies the process of generating and displaying images using Pollinations' API.
import React from 'react';
import { PollinationsImage } from 'pollinations-react';
const MyComponent = () => (
<PollinationsImage prompt="A beautiful sunset over the ocean" />
);
export default MyComponent;
Development
Local Development
To develop this package locally, follow these steps:
- Clone the repository:
git clone https://github.com/your-username/pollinations-react.git
cd pollinations-react
- Install dependencies:
npm install
- Start the development server:
npm run dev
Publishing
To publish the package to npm, run:
npm publish --access public
License
This project is licensed under the MIT License. See the LICENSE file for details.
Made with ❤️ by the Pollinations.AI team