npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@saru2/gemini-image-generator

v0.1.0

Published

Reusable Gemini image generator component for React.

Readme

@saru2/gemini-image-generator

Reusable "ImageGenerator" React component extracted from the Saru2 Gemini image playground. The component stays client-side only and posts prompts plus optional image uploads to your API.

Installation

npm install @saru2/gemini-image-generator
# or
pnpm add @saru2/gemini-image-generator

Usage

"use client";

import { ImageGenerator } from "@saru2/gemini-image-generator";

export default function Playground() {
  return (
    <ImageGenerator
      endpoint="/api/generate-image"
      onResultChange={(result) => {
        if (result.type === "error") {
          console.error("Generation failed", result.message);
        }
      }}
    />
  );
}

The component ships with Tailwind-powered styles used by the Saru2 playground. You can pass a custom className to the root container or fork the component if you need a different look.

Props

| Prop | Type | Default | Description | | --- | --- | --- | --- | | endpoint | string | "/api/generate-image" | REST endpoint that accepts the JSON payload documented below. | | requestHeaders | HeadersInit \| (ctx) => HeadersInit | undefined | Optional headers (static or dynamic) merged with Content-Type: application/json. Useful for auth tokens. | | fetchImplementation | typeof fetch | global fetch | Provide a custom fetch implementation if needed (e.g. wrapped fetch with interceptors). | | className | string | undefined | Appends extra classes to the outer <section>. | | onResultChange | (result: Result) => void | undefined | Observe every state change (idle, loading, error, image, text). | | initialPrompt | string | "" | Prefill the textarea. | | defaultAspect | "1:1" \| "16:9" \| "9:16" \| "4:3" \| "3:4" | "1:1" | Initial aspect ratio.

Request body format

{
  "prompt": "Final prompt string",
  "imageBase64": "base64 string (optional, legacy single-image field)",
  "mimeType": "image/png",
  "images": [
    {
      "mimeType": "image/png",
      "dataBase64": "..."
    }
  ]
}

If the user selects a non-square aspect ratio without uploads, the component attaches a blank PNG canvas to images[0] to hint orientation.

Building locally

# from packages/image-generator
npm install
npm run build

The build emits ESM, CJS, and type declarations under dist/. Update the name field in package.json to match your npm scope before publishing.

Publishing

npm login
npm publish --access public

Remember to bump the version for every release and keep your API handler compatible with the payload above.