npm.io
1.0.0-beta.4 • Published yesterday

@nifrajs/client

Licence
MIT
Version
1.0.0-beta.4
Deps
0
Size
57 kB
Vulns
0
Weekly
642
Stars
2

@nifrajs/client

A browser-safe, end-to-end-typed client for nifra servers — an Eden-style proxy that never throws.

bun add @nifrajs/client
import { client } from "@nifrajs/client"
import type { App } from "./server" // `typeof app` from @nifrajs/core

const api = client<App>("http://localhost:3000")

const { ok, status, data, error } = await api.users({ id: "42" }).get()
//                                          ^? typed from the server route
  • Zero codegen. Types flow from typeof app (coupled) — or from a contract via client(contract, url) (decoupled), with no dependency on the server's source.
  • Proxy chaining. Path segments are properties, :params are calls, verbs are methods: api.users({ id }).posts({ postId }).get(). The root is api.index.
  • Result, never exceptions. Every call resolves to { ok, status, data, error }, so the failure path is in the types. Bodies are positional (api.users.post({ name })); pass { query, headers, signal } as call options.
  • Environment-agnostic. No Bun/Node APIs — runs in the browser, workers, or any runtime with fetch.

ESM-only. MIT.

For AI agents

Start with LLM.md — this package's contract card (the exports you call + its footguns), one cheap read instead of the whole corpus. For the wider framework: the repo's AGENTS.md is the copy-paste quick reference, and llms-full.txt is the full machine-readable corpus. Run nifra check as the done-gate, or nifra mcp to give the agent live project tools.

Keywords