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

@dreamind-tools/mosparo-hook

v0.5.4

Published

React/Next.js integration for mosparo spam protection

Readme

@dreamind-tools/mosparo-hook

npm version license

React/Next.js integration for mosparo spam protection.

Installation

npm install @dreamind-tools/mosparo-hook

Peer dependencies

  • react ^18 or ^19
  • @mosparo/api-client ^1.2.0 (only needed for server-side verification)

Setup

Environment variables

The simplest way to configure the package is via environment variables. No props needed.

NEXT_PUBLIC_MOSPARO_HOST=https://mosparo.example.com
NEXT_PUBLIC_MOSPARO_UUID=your-project-uuid
NEXT_PUBLIC_MOSPARO_PUBLIC_KEY=your-public-key
MOSPARO_PRIVATE_KEY=your-private-key

The first three are used by both the client component and server verification. The private key is server-only and never exposed to the browser. You can find these values in your mosparo project settings.

Usage

Client: <MosparoField />

Drop the component into any form. It renders the mosparo captcha widget and automatically loads the mosparo frontend script.

import { MosparoField } from '@dreamind-tools/mosparo-hook';

export function ContactForm() {
  return (
    <form action="/api/contact" method="POST">
      <input name="name" placeholder="Name" />
      <input name="email" placeholder="Email" />
      <textarea name="message" placeholder="Message" />

      <MosparoField />

      <button type="submit">Send</button>
    </form>
  );
}

If you prefer passing config via props instead of environment variables:

<MosparoField
  host="https://mosparo.example.com"
  uuid="your-project-uuid"
  publicKey="your-public-key"
/>

Props

| Prop | Type | Description | |------|------|-------------| | host | string | mosparo instance URL | | uuid | string | Project UUID | | publicKey | string | Project public key | | options | MosparoOptions | Widget options (language, design mode, etc.) | | callbacks | MosparoCallbacks | Lifecycle callbacks | | invisibleCallbacks | MosparoInvisibleCallbacks | Invisible mode callbacks | | id | string | Custom container element ID | | className | string | CSS class for the container | | style | CSSProperties | Inline styles for the container | | onError | (error: Error) => void | Called if widget initialization fails |

Server: verifySubmission()

Verify form submissions on the server using @mosparo/api-client under the hood.

import { verifySubmission } from '@dreamind-tools/mosparo-hook/server';

Next.js Server Action

'use server';

import { verifySubmission } from '@dreamind-tools/mosparo-hook/server';

export async function submitContact(formData: FormData) {
  const result = await verifySubmission(formData);

  if (!result.valid) {
    return { error: result.error ?? 'Spam detected.' };
  }

  // Process the form...
}

Next.js API Route

import { verifySubmission } from '@dreamind-tools/mosparo-hook/server';

export async function POST(request: Request) {
  const formData = await request.formData();
  const result = await verifySubmission(formData);

  if (!result.valid) {
    return Response.json({ error: 'Verification failed.' }, { status: 422 });
  }

  // Process the form...
  return Response.json({ success: true });
}

With explicit config

const result = await verifySubmission(formData, {
  config: {
    host: 'https://mosparo.example.com',
    uuid: 'your-project-uuid',
    publicKey: 'your-public-key',
    privateKey: 'your-private-key',
  },
  excludeFields: ['honeypot'],
});

Return type

interface VerifySubmissionResult {
  success: boolean;          // Whether the API call succeeded
  valid: boolean;            // Whether the submission passed verification
  verifiedFields: Record<string, string>;
  issues: unknown[];
  error?: string;            // Error message if success is false
}

License

MIT