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

@ngivanyh/bfa

v2.0.0

Published

A simple schema-driven data-fetching library reconciling the frontend and backend

Downloads

34

Readme

bfa

Origin

Introduction

bfa is a pure, schema-driven data-fetching library designed to bring back the convenience of templates into modern frontends (can be additionally used for general-purpose data-fetching workflows). It bridges the gap between your frontend and backend by "reconciling" the frontend and the backend using a flexible, declarative schema system.

By defining your data requirements using typed builder classes (Int, String, Float, Bool, List, JSON), bfa dynamically compiles your constraints into a standardized payload. The core Reconcile engine then takes care of the HTTP requests, executing middlewares, and crucially validating the incoming JSON response against your schema to guarantee end-to-end type safety.

The library is completely framework-agnostic. You don't need dedicated adapters or wrappers for React, Vue, or Svelte. bfa is simple enough to retrieve validated data in a single line so you can instantly pass it to your components. It also doesn't matter what your backend passes back to the frontend, bfa will always validate the response against your schema, promptly throwing an error if the response doesn't match.

Quick Example

import { Schema, Types, Reconcile } from 'bfa';

// 1. Define your schema constraints
const userSchema = new Schema({
  id: Types.Int().min(1),
  username: Types.String().minLength(3),
});

// 2. Setup your Reconcile client with optional middleware
const api = new Reconcile('https://api.example.com/user', userSchema)
  .use(async (context, next) => {
    // Add auth headers dynamically
    context.options.headers = {
      ...context.options.headers,
      'Authorization': 'Bearer YOUR_TOKEN'
    };
    const response = await next(context);
    console.log(`[bfa] Fetched ${context.url} - Status: ${response.status}`);
    return response;
  });

// 3. Fetch and get guaranteed, validated data in one line
const data = await api.fetch(); 
// If the backend returns an invalid string or missing ID, bfa throws a clear validation error.

How It Compares to Existing Solutions

bfa fills a unique space in the modern ecosystem, focusing on pure simplicity and decoupling:

  • vs. GraphQL (Apollo/Relay): GraphQL requires adopting a specific query language and setting up a heavy client cache. bfa relies on pure JavaScript objects and maps effortlessly to standard REST-like endpoints without the boilerplate.
  • vs. tRPC: tRPC is fantastic for full-stack TypeScript monorepos, but it deeply couples your frontend and backend. bfa allows you to define your expected contract strictly on the client side, making it perfect for integrating with third-party APIs or backends written in other languages (Go, Python, Rust).
  • vs. Zod + Fetch / Axios: While you can manually write fetch wrappers and pass the results to a Zod schema, bfa combines the payload generation (compilation), the fetch execution, middleware pipelines, and validation into a single cohesive Reconcile lifecycle.

Roadmap & Future Suggestions

bfa intentionally avoids bloat like framework-specific hooks, keeping the footprint minimal. However, here are a few logical steps for the future that maintain its core philosophy:

Performance-Oriented Improvements

  • Schema Compilation to Fast Validation Functions: Compile schemas into reusable JavaScript validation functions for faster validation, especially with large or deeply nested data.
  • Async/Batched Validation for Large Payloads: Provide an async validation mode for very large arrays/objects to keep UIs responsive and avoid blocking the main thread.

Generality & Feature-Oriented Improvements

  • Complex Primitives: Expand the Types dictionary to include Date (with auto-parsing from ISO strings), Enum, Email, and UUID for more robust validations.
  • Better Error Reporting: Include full paths and context in validation errors, and optionally collect all errors instead of failing fast.
  • Schema Introspection & Serialization: Allow schemas to be serialized to JSON and introspected at runtime for auto-generating forms, docs, or backend integration.