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

@kloddy/kloddy-js

v0.1.1

Published

Kloddy JS SDK

Readme

@kloddy/kloddy-js

Kloddy is the ultimate platform for Prompt Engineering and LLM Analytics. This SDK allows you to fetch, compile, and execute prompts directly from your Node.js or React applications with full type safety and zero-config support.

Installation

# via npm
npm install @kloddy/kloddy-js

# via yarn
yarn add @kloddy/kloddy-js

Quick Start

Zero-Config Initialization (Node.js)

Kloddy automatically looks for KLODDY_API_KEY and KLODDY_API_SECRET in your environment variables.

import { Kloddy } from '@kloddy/kloddy-js';

// Zero-config! Uses process.env.KLODDY_API_KEY and process.env.KLODDY_API_SECRET
const kloddy = new Kloddy();

// Type-safe prompts (Optional but recommended)
type MyPrompts = 'exam-generator' | 'customer-support' | 'welcome-email';
const kloddyTyped = new Kloddy<MyPrompts>();

// One-step execution (Play)
const { result } = await kloddyTyped.prompts.play('exam-generator', {
  variables: { locale: 'en-US', topic: 'Physics' }
});

console.log(result);

Next.js Integration (App Router)

Securely generate tokens on the server without exposing secrets to the client.

// app/api/kloddy/token/route.ts
import { createKloddyAdapter } from '@kloddy/kloddy-js/next';

export const GET = createKloddyAdapter({
  // Credentials picked up from env vars automatically
});

React Hooks

Wrap your application with KloddyProvider and use the simplified hooks.

// app/layout.tsx
import { KloddyProvider } from '@kloddy/kloddy-js';

export default function RootLayout({ children }) {
  return (
    <KloddyProvider authEndpoint="/api/kloddy/token">
      {children}
    </KloddyProvider>
  );
}

// components/PromptExecutor.tsx
'use client';
import { usePrompt } from '@kloddy/kloddy-js';

export function PromptExecutor() {
  const { getAwnser, isLoading } = usePrompt<'exam-generator'>();

  const handleRun = async () => {
    const { result } = await getAwnser('exam-generator', {
      variables: { topic: 'Math' }
    });
    alert(result);
  };

  return (
    <button onClick={handleRun} disabled={isLoading}>
      {isLoading ? 'Running...' : 'Generate Exam'}
    </button>
  );
}

Features

  • Zero-Config: Works out of the box with process.env.
  • Type Safety: Use Generics to get autocomplete for your prompt names.
  • Next.js Ready: Built-in adapter for secure token handling.
  • Graceful Degradation: Built-in fallback support for offline mode or API issues.
  • Professional Error Handling: Custom error classes like KloddyAuthError and KloddyNotFoundError.
  • Tree-Shakable: Optimized for small bundle sizes.

API Reference

Kloddy<TPromptNames>

The main entry point for the SDK.

  • prompts.get(name, options): Fetch a template with optional version and fallback.
  • prompts.play(name, options): Execute a prompt directly in one step.
  • prompts.compile(template, variables): Locally compile a template string.
  • evaluations.run(options): Run model evaluations.

React Hooks

  • usePrompt<TPromptNames>(): Manage prompts and execution state.
  • useEvaluations(): Manage model evaluations and comparisons.
  • usePromptStream<TPromptNames>(): Support for streaming responses.

Advanced Fallback Strategy

Prevent outages by providing a local fallback for critical prompts.

const template = await kloddy.prompts.get('critical-prompt', {
  fallback: 'You are a helpful assistant. (Offline Fallback)'
});

License

MIT © Kloddy