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

@irondome/next

v0.1.3

Published

Next.js App Router helpers for Irondome permissions

Downloads

452

Readme

@irondome/next

Integração Next.js (App Router) — o mesmo can() no middleware, APIs, tRPC e UI.

Pilar: como o pedido HTTP chega ao motor PBAC — rotas, JSON, hooks e Server Actions.

Parte do monorepo Irondome — espelha as secções Middleware, Hook React e tRPC do README principal.


O que é?

@irondome/next liga @irondome/core (e opcionalmente @irondome/auth) ao ciclo de vida do Next.js: createRoutePermissionMiddleware, runPermissionGuard, usePermission, createIrondomeContext, irondomePermission, withPermission, respostas forbiddenJson / unauthorizedJson.

Não redefine políticas — apenas transporta Subject + can() para o sítio certo.


Instalação

pnpm add @irondome/next @irondome/core @irondome/auth next react

Dependências

| Tipo | Pacotes | |------|---------| | Peer | @irondome/core, @irondome/auth, next, react |


O que inclui

| API | Uso | |-----|-----| | createRoutePermissionMiddleware | middleware.ts — mesmas regras que no servidor | | runPermissionGuard | app/api/.../route.ts | | forbiddenJson / unauthorizedJson | Respostas 403 / 401 | | usePermission | Componentes 'use client' | | createIrondomeContext | Contexto tRPC com can / authorize | | irondomePermission | Middleware de procedure tRPC | | withPermission | Server Actions |


Exemplo rápido (middleware)

import { createRoutePermissionMiddleware } from "@irondome/next";
import { actions, pageResource } from "@irondome/core";
import { verifyToken } from "@irondome/auth/jwt";
import { can } from "./lib/permissions";

export default createRoutePermissionMiddleware({
  getSubject: async (req) => {
    const token = /* cookie */;
    const payload = await verifyToken(token, process.env.JWT_SECRET!);
    return payload ? { id: payload.sub, roles: payload.roles, orgId: payload.orgId } : null;
  },
  can,
  publicPaths: ["/", "/api/auth/*"],
  rules: [
    { match: (p) => p.startsWith("/admin"), action: actions.page.visit, resource: (p) => pageResource(p) },
  ],
});

(Igual ao README do monorepo, secção Middleware.)


Hook React (client)

import { usePermission } from "@irondome/next";
import { namedResource } from "@irondome/core";

const { allowed } = usePermission(can, user, "resource:delete", namedResource("post", post.id));
return allowed ? <DeleteButton /> : null;

tRPC

import { createIrondomeContext, irondomePermission } from "@irondome/next";
import { namedResource } from "@irondome/core";
import { can } from "@/lib/irondome/permissions";

export const createTRPCContext = async () => {
  const subject = await getServerSubject();
  return { ...createIrondomeContext(can, subject) };
};

const canDelete = irondomePermission(can, "resource:delete", (input: { id: string }) =>
  namedResource("post", input.id),
);

(Detalhes no README do monorepo, secção tRPC.)


Relação com outros pacotes

| Pacote | Função | |--------|--------| | @irondome/core | Exporta can / createPermissions | | @irondome/auth | verifyToken no Edge; sessão em Server Components |


Documentação

| Recurso | Ligação | |---------|---------| | Monorepo | README Irondome | | Quatro pilares | Guia dos pilares | | Publicar no npm | npm-publish |


Licença

MIT © rbxyz