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

@longzai-intelligence-transport/http-adapter-react

v0.2.0

Published

Readme

@longzai-intelligence-transport/http-adapter-react

React Hooks 适配器,基于 SWR 提供类型安全的 Query、Mutation、Infinite Hook 工厂。

安装

bun add @longzai-intelligence-transport/http-adapter-react

功能特性

  • Query Hook 工厂 - 创建类型安全的数据查询 Hook
  • Mutation Hook 工厂 - 创建类型安全的数据变更 Hook
  • Infinite Hook 工厂 - 创建类型安全的无限滚动 Hook
  • 完整的 TypeScript 支持 - 自动推断参数和返回类型

依赖

  • react - React 框架(peer dependency,>=18.0.0)
  • swr - SWR 数据请求库(peer dependency,>=2.0.0)
  • zod - Schema 验证(peer dependency)
  • @longzai-intelligence-transport/http-core - 核心模块

使用示例

Query Hook

import { createQueryHook } from '@longzai-intelligence-transport/http-adapter-react';

const useGetUser = createQueryHook(getUserApi, 'user');
const { data, error, isLoading } = useGetUser({ id: '123' });

Mutation Hook

import { createMutationHook } from '@longzai-intelligence-transport/http-adapter-react';

const useCreateUser = createMutationHook(createUserApi);
const { trigger, isMutating } = useCreateUser();
await trigger({ body: { name: 'John' } });

Infinite Hook

import { createInfiniteHook } from '@longzai-intelligence-transport/http-adapter-react';

const useUserList = createInfiniteHook(getUserListApi);
const { data, size, setSize, isLoadingMore } = useUserList();

导出模块

Query Hook

  • createQueryHook - 创建查询 Hook 工厂函数
  • QueryHookFunction - 查询 Hook 函数类型
  • QueryHookReturn - 查询 Hook 返回类型
  • QueryHookNoParams - 无参数查询 Hook 类型
  • QueryHookWithParams - 带路径参数查询 Hook 类型
  • QueryHookWithQuery - 带查询参数 Hook 类型
  • QueryHookWithParamsAndQuery - 带路径和查询参数 Hook 类型

Mutation Hook

  • createMutationHook - 创建变更 Hook 工厂函数
  • MutationHookFunction - 变更 Hook 函数类型
  • MutationHookReturn - 变更 Hook 返回类型
  • MutationTriggerArgs - 触发器参数类型
  • MutationTriggerNoArgs - 无参数触发器类型
  • MutationTriggerWithParams - 带路径参数触发器类型
  • MutationTriggerWithBody - 带请求体触发器类型
  • MutationTriggerWithParamsAndBody - 带路径参数和请求体触发器类型

Infinite Hook

  • createInfiniteHook - 创建无限滚动 Hook 工厂函数
  • InfiniteHookFunction - 无限滚动 Hook 函数类型
  • InfiniteHookReturn - 无限滚动 Hook 返回类型
  • ExtractPageItem - 提取分页项类型

许可证

UNLICENSED