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

@fajarmaulana/komerce-lp-helper

v0.3.3

Published

Helper functions, hooks, and utils for Komerce LP

Readme

komerce-lp-helper

A collection of useful React hooks, utilities, and helper functions designed for Komerce Landing Page projects.

Installation

npm install @fajarmaulana/komerce-lp-helper

Features

HTTP Client & API Hooks

http

A wrapper around fetch with support for interceptors, caching, and retries.

import { http } from 'komerce-lp-helper'

// GET request
const users = await http.get('/users')

// POST request with body
await http.post('/users', { name: 'John Doe' })

// Using cache
const cachedData = http.getCache('my-key')

createApi

Creates a new API instance with built-in React hooks (fetch, mutation, infinite) for performing typed data fetching and mutations with progress tracking.

import { createApi } from 'komerce-lp-helper'

const api = createApi({ baseURL: '/api' })

// Fetch
const { data, isLoading, refetch } = api.fetch<User[]>('/users')

// Mutation (POST, PUT, DELETE)
const { mutate, isLoading, progress } = api.mutation<User, FormData>('/users', { method: 'POST' })

// Infinite Fetch
const { data, fetchNextPage } = api.infinite<User[]>('/users', {
  initialOffset: 0,
  setOffset: (lastItems, allItems, lastOffset) => (lastItems.length ? lastOffset + 1 : null),
})

Hooks

useDebounce

Returns a debounced version of a value. Useful for delaying expensive operations.

import { useDebounce } from 'komerce-lp-helper'
const debouncedSearchTerm = useDebounce(searchTerm, 500)

useDebounceFunc

Returns a debounced version of a callback function.

import { useDebounceFunc } from 'komerce-lp-helper'
const debouncedSearch = useDebounceFunc(q => fetchResults(q), 300)

useConditionalDebounce

Conditionally executes a callback function after a specified debounce delay.

useRouter

A custom router API built on top of React Router DOM that provides easier navigation methods and state management.

import { useRouter } from 'komerce-lp-helper'

const { push, replace, back, query, params } = useRouter()

// Navigate with query params
push({ pathname: '/dashboard', query: { tab: 'settings' } })

useQueryParams

A hook for reading and updating query parameters in the URL locally.

import { useQueryParams } from 'komerce-lp-helper'
const [queryObj, updateQuery] = useQueryParams<{ page: string }>()

useSlider

Manages logic for custom slider components, including touch/drag support and navigation.

import { useSlider } from 'komerce-lp-helper'
const slider = useSlider({ data: items })

useForm

Manages form fields, retrieval of values, and error handling for both named inputs and standalone fields.

import { useForm } from 'komerce-lp-helper'

const { form, fields, fieldsWithoutName } = useForm<{ email: string }>(['custom-input-id'])

const handleSubmit = e => {
  e.preventDefault()
  const data = fields()
  console.log(data.email.field_value)
}

useSectionObserver

Trigger animations or state changes when a section comes into view.

import { useSectionObserver } from 'komerce-lp-helper'

const ref = useRef(null)
useSectionObserver({ triggerRef: ref, targetId: 'target-section' })

Utilities

Cookie

Managed wrappers for document.cookie.

  • setCookie({ key, value, maxAge }): Sets a cookie.
  • setCookies([ ... ]): Sets multiple cookies.
  • getCookie(key): Gets and parses a cookie value.
  • getCookies([keys]): Retrieves multiple cookies.
  • removeCookie(key): Removes a cookie.
  • removeCookies([keys]): Removes multiple cookies.
  • clearCookies(): Clears all cookies.

Local Storage

Type-safe wrappers for localStorage.

  • setLocal(key, value): Stores a value (JSON stringified).
  • setLocals([ ... ]): Stores multiple values.
  • getLocal(key): Retrieves and parses a value.
  • getLocals([keys]): Retrieves multiple values.
  • removeLocal(key): Removes an item.
  • clearLocals(): Clears local storage.

File

Helpers for file and blob manipulation.

  • checkImage(url): Checks if an image URL is valid.
  • convertBlob(blob): Converts a Blob to a Base64 string.
  • extension(mimeType): Gets file extension from MIME type.
  • filenameWithExtension(blob, prefix): Generates a filename.
  • createDownloadAnchor(blob, options): Creates an anchor for downloading.
  • downloadBlob(blob, filename): Triggers a file download.

General

Common DOM and string utilities.

  • getById(id): Type-safe document.getElementById.
  • getByAny(selector): Type-safe document.querySelector.
  • clickById(id): Triggers a click on an element by ID.
  • focusById(id): Focuses an element by ID.
  • handleHashLink(hash, currentHash): Smooth scrolling for hash links.
  • acronym(name): Generates a 2-letter acronym from a name.
  • isNotPrimitive(value): Checks if a value is an object/array.

Form Validation

Helpers for validating inputs and displaying error messages.

  • provideFieldError(params): Validates a field against a set of rules and updates the error element.
  • providePasswordFieldError(params): Specialized validation for password strength (length, uppercase, lowercase, numbers, symbols).

Components

  • Form: A wrapper component for HTML forms.
  • LazyBackground: Component for lazy loading background images.

License

MIT