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

@lescd/tipc

v0.5.0

Published

Type-safe IPC for Electron with end-to-end type safety, built on Zod schemas.

Downloads

851

Readme

TIPC

Type-safe IPC for Electron with end-to-end type safety, built on Zod schemas.

Features

  • End-to-end type safety - From main process to renderer, types are preserved
  • Zod validation - Runtime validation with Zod schemas for inputs and outputs
  • Result types - No thrown exceptions, explicit error handling with Result<T, E>
  • Middleware support - Composable middleware for auth, logging, caching, etc.
  • Event system - Type-safe events from main to renderer
  • React integration - React hooks and React Query integration for seamless UI updates
  • Zero boilerplate - Minimal setup, maximum type inference

Installation

npm install @lescd/tipc zod

Quick Start

Main Process

import { tipc } from '@lescd/tipc/main'
import { z } from 'zod'

const t = tipc.create()

export const router = {
  greet: t.procedure
    .input(z.object({ name: z.string() }))
    .action(({ input }) => `Hello, ${input.name}!`),

  getUser: t.procedure
    .input(z.object({ id: z.number() }))
    .action(async ({ input }) => {
      const user = await db.users.findOne({ id: input.id })
      return user
    }),
}

export const events = tipc.events({
  userUpdated: z.object({
    userId: z.number(),
    name: z.string(),
  }),
})

tipc.register({ router, events })

Renderer Process

import { createClient } from '@lescd/tipc/react'
import type { router, events } from '../main'

export const tipc = createClient<typeof router, typeof events>()

// Call procedures
const result = await tipc.greet({ name: 'World' })

if (result.ok) {
  console.log(result.data) // "Hello, World!"
} else {
  console.error(result.error.message)
}

// React hook
function UserProfile({ userId }: { userId: number }) {
  const userQuery = tipc.useQuery('getUser', { id: userId })
  
  if (userQuery.isLoading) return <div>Loading...</div>
  if (userQuery.isError) return <div>Error: {userQuery.error.message}</div>
  
  return <div>Welcome, {userQuery.data.name}!</div>
}

Documentation

Comprehensive documentation is included in this package:

Start with the Introduction or jump to Getting Started.

API Overview

Main Process

  • tipc.create() - Create a TIPC instance
  • t.procedure - Define a type-safe procedure
    • .input(schema) - Define input validation (optional)
    • .output(schema) - Define output validation (optional)
    • .action(handler) - Implement the procedure logic
    • .use(middleware) - Add middleware
  • tipc.events(schemas) - Define event schemas
  • tipc.register({ router, events }) - Register procedures and events with Electron

Renderer Process

  • createClient<Router, Events>() - Create typed client
  • tipc.procedureName(input) - Call a procedure, returns Promise<Result<T, E>>
  • tipc.useQuery(name, input) - React Query hook for procedures
  • tipc.useMutation(name) - React Query mutation hook
  • tipc.useEvent(name, handler) - React hook for events

Examples

See the examples directory for a complete working example.

Result Type

TIPC uses explicit Result types instead of throwing exceptions:

type Result<T, E extends Error> =
  | { ok: true; data: T }
  | { ok: false; error: E }

This forces explicit error handling and makes errors part of the type signature.

Middleware

Middleware can be used for cross-cutting concerns:

const authMiddleware = t.middleware
  .context<{ userId: number }>()
  .build(async ({ context, next }) => {
    const userId = await validateSession(context.sender)
    return next({ ...context, userId })
  })

const protectedProcedure = t.procedure
  .use(authMiddleware)
  .action(({ context }) => {
    // context.userId is available here
    return { success: true }
  })

TypeScript

TIPC is built with TypeScript and provides complete type safety:

  • Input/output types are inferred from Zod schemas
  • Procedure calls are type-checked in the renderer
  • Event payloads are typed
  • Middleware context is typed

License

MIT

Contributing

Contributions are welcome! Please see the documentation for architecture details and best practices.