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

@json-render/core

v0.3.0

Published

JSON becomes real things. Define your catalog, register your components, let AI generate.

Downloads

9,550

Readme

@json-render/core

Predictable. Guardrailed. Fast. Core library for safe, user-prompted UI generation.

Features

  • Conditional Visibility: Show/hide components based on data paths, auth state, or complex logic expressions
  • Rich Actions: Actions with typed parameters, confirmation dialogs, and success/error callbacks
  • Enhanced Validation: Built-in validation functions with custom catalog functions support
  • Type-Safe Catalog: Define component schemas using Zod for full type safety
  • Framework Agnostic: Core logic is independent of UI frameworks

Installation

npm install @json-render/core
# or
pnpm add @json-render/core

Quick Start

Create a Catalog

import { createCatalog } from '@json-render/core';
import { z } from 'zod';

const catalog = createCatalog({
  name: 'My Dashboard',
  components: {
    Card: {
      props: z.object({
        title: z.string(),
        description: z.string().nullable(),
      }),
      hasChildren: true,
      description: 'A card container',
    },
    Button: {
      props: z.object({
        label: z.string(),
        action: ActionSchema,
      }),
      description: 'A clickable button',
    },
  },
  actions: {
    submit: { description: 'Submit the form' },
    export: { 
      params: z.object({ format: z.enum(['csv', 'pdf']) }),
      description: 'Export data',
    },
  },
  functions: {
    customValidation: (value) => typeof value === 'string' && value.length > 0,
  },
});

Visibility Conditions

import { visibility, evaluateVisibility } from '@json-render/core';

// Simple path-based visibility
const element1 = {
  key: 'error-banner',
  type: 'Alert',
  props: { message: 'Error!' },
  visible: { path: '/form/hasError' },
};

// Auth-based visibility
const element2 = {
  key: 'admin-panel',
  type: 'Card',
  props: { title: 'Admin' },
  visible: { auth: 'signedIn' },
};

// Complex logic
const element3 = {
  key: 'notification',
  type: 'Alert',
  props: { message: 'Warning' },
  visible: {
    and: [
      { path: '/settings/notifications' },
      { not: { path: '/user/dismissed' } },
      { gt: [{ path: '/items/count' }, 10] },
    ],
  },
};

// Evaluate visibility
const isVisible = evaluateVisibility(element1.visible, {
  dataModel: { form: { hasError: true } },
});

Rich Actions

import { resolveAction, executeAction } from '@json-render/core';

const buttonAction = {
  name: 'refund',
  params: {
    paymentId: { path: '/selected/id' },
    amount: 100,
  },
  confirm: {
    title: 'Confirm Refund',
    message: 'Refund $100 to customer?',
    variant: 'danger',
  },
  onSuccess: { navigate: '/payments' },
  onError: { set: { '/ui/error': '$error.message' } },
};

// Resolve dynamic values
const resolved = resolveAction(buttonAction, dataModel);

Validation

import { runValidation, check } from '@json-render/core';

const config = {
  checks: [
    check.required('Email is required'),
    check.email('Invalid email'),
    check.maxLength(100, 'Too long'),
  ],
  validateOn: 'blur',
};

const result = runValidation(config, {
  value: '[email protected]',
  dataModel: {},
});

// result.valid = true
// result.errors = []

API Reference

Visibility

  • evaluateVisibility(condition, context) - Evaluate a visibility condition
  • evaluateLogicExpression(expr, context) - Evaluate a logic expression
  • visibility.* - Helper functions for creating visibility conditions

Actions

  • resolveAction(action, dataModel) - Resolve dynamic values in an action
  • executeAction(context) - Execute an action with callbacks
  • interpolateString(template, dataModel) - Interpolate ${path} in strings

Validation

  • runValidation(config, context) - Run validation checks
  • runValidationCheck(check, context) - Run a single validation check
  • builtInValidationFunctions - Built-in validators (required, email, min, max, etc.)
  • check.* - Helper functions for creating validation checks

Catalog

  • createCatalog(config) - Create a catalog with components, actions, and functions
  • generateCatalogPrompt(catalog) - Generate an AI prompt describing the catalog

Types

See src/types.ts for full type definitions:

  • UIElement - Base element structure
  • UITree - Flat tree structure
  • VisibilityCondition - Visibility condition types
  • LogicExpression - Logic expression types
  • Action - Rich action definition
  • ValidationConfig - Validation configuration