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

@xiao-ying/miniapp-hooks

v1.1.0

Published

React hooks for @xiao-ying/miniapp-sdk to build reactive miniapp UIs

Downloads

90

Readme

@xiao-ying/miniapp-hooks

基于 @xiao-ying/miniapp-sdk 的通用 React hooks(不包含 cloud/snapshot)。

安装

pnpm add @xiao-ying/miniapp-hooks @xiao-ying/miniapp-sdk react

Hook 列表

  • useBrightness():订阅原生/浏览器亮度变化,返回 { brightness, isDark }
  • useForeground():订阅前后台变化,返回 { isForeground }
  • useMediaQuery():暴露注入的 mediaQuery(安全区、DPR、尺寸)。
  • useStorage(key, options?):与 xy.onStorageChange 同步,提供 valueloadingerror 以及 setValue/remove/refresh
  • useShare(input?):注册分享处理器,自动补齐默认 path/title。
  • useHapticFeedback(options?)(别名 useHapticPress):封装 xy.vibrate
  • useSdkError(options?):订阅 xy.onError,缓存过滤后的错误并返回 latesterrorsclear
  • useAuthState():订阅登录态变化,返回 { authState, hasAuthPermission, isSignedIn, userId }

cloud/snapshot hooks 已迁移到:

  • @xiao-ying/miniapp-cloud-kit(core API)
  • @xiao-ying/miniapp-cloud-hooks(SWR hooks)

快速示例

import { useBrightness, useStorage } from '@xiao-ying/miniapp-hooks'

const Preferences = () => {
  const { brightness, isDark } = useBrightness()
  const theme = isDark ? 'dark' : 'light'
  const storage = useStorage<string>('nickname', { defaultValue: '游客' })

  return (
    <div data-theme={theme}>
      <p>当前模式: {brightness}</p>
      <input
        value={storage.value ?? ''}
        onChange={(e) => storage.setValue(e.target.value)}
        placeholder="输入昵称"
      />
    </div>
  )
}