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

sdnext

v0.0.25

Published

`sdnext` 是一个面向 `Next.js` 项目的轻量生成工具,用来基于 `shared/**` 自动生成 `actions/**`、`app/api/actions/**/route.ts`,以及基于 `actions/**` 生成 `hooks/**`。

Readme

sdnext

sdnext 是一个面向 Next.js 项目的轻量生成工具,用来基于 shared/** 自动生成 actions/**app/api/actions/**/route.ts,以及基于 actions/** 生成 hooks/**

约定

shared -> action

shared/addUser.ts

export async function addUser() {}

会生成:

actions/addUser.ts

"use server"

import { createResponseFn } from "@/server/createResponseFn"

import { addUser } from "@/shared/addUser"

export const addUserAction = createResponseFn(addUser)

shared -> route

如果源函数显式声明了 route 元数据:

export async function addUser() {}

addUser.route = true

或:

export async function addUser() {}

addUser.route = {}

会额外生成:

app/api/actions/add-user/route.ts

import { createRoute } from "@/server/createResponseFn"

import { addUser } from "@/shared/addUser"

export const { POST } = createRoute(addUser)

默认情况下,fn.route 视为 false,不会生成 route。

actions -> hook

执行 sdnext hook 后,会根据 actions/** 生成 hooks/**

命名规则:

  • getUser 默认识别为 get
  • queryUser 默认识别为 query
  • 其他函数默认识别为 mutation

命令

build

sdnext build next build

执行顺序:

  1. 同步生成 actions/**
  2. 根据 fn.route 同步生成 app/api/actions/**
  3. 再执行后续命令

dev

sdnext dev next dev

行为与 build 类似,但会额外监听 shared/** 的新增、修改、删除,并实时同步生成物。

hook

sdnext hook

扫描 actions/** 并交互式生成或覆盖 hooks/**

路径映射

  • shared/addUser.ts -> actions/addUser.ts
  • shared/addUser.ts -> app/api/actions/add-user/route.ts
  • shared/admin/addUser.ts -> actions/admin/addUser.ts
  • shared/admin/addUser.ts -> app/api/actions/admin/add-user/route.ts

说明

  • 只处理 .ts.tsx.js.jsx
  • 生成文件会做幂等比较,内容未变化时不会重复写入
  • 删除 shared 文件或移除 fn.route 后,对应生成物会自动清理
  • sdnext buildsdnext dev 会自动把 actions/**app/api/actions/** 写入 .vscode/settings.jsonfiles.exclude