Catalog npm
Back to packageRELEASE DETAILS

0.1.8

npm

@0x1luxa/hooks

A collection of hooks for React

hooksreactweb3
Published19 Mar 2025
Direct dependencies9
Transitive dependenciesNot calculated

README

Current package documentation

@0x1luxa/hooks

A collection of hooks for React, designed to simplify state management and interaction with web3.

Installation

To install the package, use npm or yarn:

npm install @0x1luxa/hooks

or

yarn add @0x1luxa/hooks

Usage

Common Hooks

useClipboard

A hook to copy text to the clipboard.

Example:

import { useClipboard } from "@0x1luxa/hooks"

const Component = () => {
  const [copy] = useClipboard()

  return (
    <button onClick={() => copy("Text to copy")}>
      Copy to Clipboard
    </button>
  )
}

useDeviceWidth

A hook to determine the device width and breakpoints.

Example:

import { useDeviceWidth } from "@0x1luxa/hooks"

const Component = () => {
  const { isBelowDesktop, isTablet, isMobile } = useDeviceWidth()

  return (
    <div>
      {isMobile && <p>Mobile View</p>}
      {isTablet && <p>Tablet View</p>}
      {isBelowDesktop && <p>Below Desktop View</p>}
    </div>
  )
}

useDimensions

A hook to get the dimensions of a DOM element.

Example:

import { useDimensions } from "@0x1luxa/hooks"
import { useRef } from "react"

const Component = () => {
  const ref = useRef<HTMLDivElement>(null)
  const dimensions = useDimensions(ref)

  return (
    <div ref={ref}>
      Width: {dimensions.width}, Height: {dimensions.height}
    </div>
  )
}

useDisclosure

A hook to manage the open/close state of a component.

Example:

import { useDisclosure } from "@0x1luxa/hooks"

const Component = () => {
  const [isOpen, { open, close, toggle }] = useDisclosure()

  return (
    <div>
      <button onClick={toggle}>Toggle</button>
      {isOpen && <p>Content is open</p>}
    </div>
  )
}

useLocalStorage

A hook to manage state with local storage.

Example:

import { useLocalStorage } from "@0x1luxa/hooks"

const Component = () => {
  const [value, setValue] = useLocalStorage("key", "default")

  return (
    <div>
      <input
        value={value}
        onChange={(e) => setValue(e.target.value)}
      />
    </div>
  )
}

usePagination

A hook to handle pagination logic.

Example:

import { usePagination } from "@0x1luxa/hooks"

const Component = () => {
  const { currentPage, totalPages, setPage } = usePagination(10, 100)

  return (
    <div>
      <button onClick={() => setPage(currentPage - 1)}>
        Previous
      </button>
      <span>
        Page {currentPage} of {totalPages}
      </span>
      <button onClick={() => setPage(currentPage + 1)}>Next</button>
    </div>
  )
}

useToggleBooleanState

A hook to toggle a boolean state every 1.5 seconds when data is available.

Example:

import { useToggleEvery1_5Sec } from "@0x1luxa/hooks"

const Component = ({ data }) => {
  const [toggle, resetToggle] = useToggleEvery1_5Sec(data)

  return (
    <div>
      <p>Toggle is {toggle ? "ON" : "OFF"}</p>
      <button onClick={resetToggle}>Reset</button>
    </div>
  )
}

Web3 Hooks

useApproveToken

A hook to handle token approval transactions.

Example:

import { useApproveToken } from "@0x1luxa/hooks"

const Component = () => {
  const { approve, isLoading } = useApproveToken({
    tokenAddress: "0xTokenAddress",
    spenderAddress: "0xSpenderAddress",
    amount: BigInt(1000),
  })

  return (
    <button onClick={approve} disabled={isLoading}>
      Approve Token
    </button>
  )
}

useTokenBalance

A hook to get the balance of a token.

Example:

import { useTokenBalance } from "@0x1luxa/hooks"

const Component = () => {
  const balance = useTokenBalance("0xTokenAddress")

  return <div>Token Balance: {balance}</div>
}

Scripts

  • build: Compiles the TypeScript code to JavaScript.
  • patch-push: Increments the patch version and pushes the tags to the repository.

Development

To build the project, run:

npm run build

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

Author

0x1luxa

Keywords

  • hooks
  • react
  • web3

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 9

Native requirements
9 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
tsup
Environment
{
  "local_name": "tsup",
  "alias": false,
  "peer_metadata": null
}
^8.4.0runtime
viem
Environment
{
  "local_name": "viem",
  "alias": false,
  "peer_metadata": null
}
^2.23.12runtime
dayjs
Environment
{
  "local_name": "dayjs",
  "alias": false,
  "peer_metadata": null
}
^1.11.13runtime
react
Environment
{
  "local_name": "react",
  "alias": false,
  "peer_metadata": null
}
^19.0.0runtime
wagmi
Environment
{
  "local_name": "wagmi",
  "alias": false,
  "peer_metadata": null
}
^2.14.15runtime
bignumber.js
Environment
{
  "local_name": "bignumber.js",
  "alias": false,
  "peer_metadata": null
}
^9.1.2runtime
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^22development
@types/react
Environment
{
  "local_name": "@types/react",
  "alias": false,
  "peer_metadata": null
}
^19.0.11development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "f952f40b401b26bf8fa276dbacecd15dea4767ee",
  "tarball": "https://registry.npmjs.org/@0x1luxa/hooks/-/hooks-0.1.8.tgz",
  "fileCount": 4,
  "integrity": "sha512-CORL8ilIHlOO/6etqb7u4KzOLqvcK2SiWL1r7eXUvR5lDD3cG6ekYQ3EUhc6b8Ez9Zbe9FwdykGrgHq4uc4CgQ==",
  "signatures": [
    {
      "sig": "MEYCIQCdeZbTm7MZRxPnDgOJnbYH7JZL38sBqur0i1cvlkBXhAIhAPXMxlKTWiTNcB0Hso3QYW9ZIkobnwXIR4iU3Vgt7DTY",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 57872
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:34 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:a657507ebd1e9c306ccd19f03e294a9848272a67d13ff70a714e1633d899dceb

Other collected versions

0.1.1119 Mar0.1.1019 Mar0.1.919 Mar0.1.719 Mar0.1.619 Mar0.1.519 MarView all collected versions →