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

@zphhpzzph/use-url-search-param

v1.0.0

Published

Vue 3 hooks for synchronizing URL search parameters with reactive state

Readme

@crm/use-url-search-param

Vue 3 hooks for synchronizing URL search parameters with reactive state.

Features

  • 🔄 Sync URL search parameters with reactive state automatically
  • 📦 Batch updates for better performance
  • 🎯 TypeScript support with full type safety
  • 🔧 Flexible options for custom parsing and formatting
  • ⚡ Built on Vue 3 Composition API and Vue Router

Installation

pnpm add @crm/use-url-search-param

Usage

useURLSearchParam

Sync a single URL search parameter with a ref:

import { useURLSearchParam } from '@crm/use-url-search-param';

// The hook will sync the 'page' URL parameter with the returned ref
const page = useURLSearchParam('page', '1');

// When page.value changes, the URL will be updated automatically
page.value = '2'; // URL becomes ?page=2

useURLSearchParams

Sync multiple URL search parameters with a reactive object:

import { useURLSearchParams } from '@crm/use-url-search-param';

// Sync multiple parameters
const filters = useURLSearchParams({
  page: 1,
  pageSize: 10,
  search: '',
});

// When filters.value changes, all URL parameters are updated
filters.value = {
  page: 2,
  pageSize: 20,
  search: 'keyword',
};
// URL becomes ?page=2&pageSize=20&search=keyword

useURLSearch

Watch a reactive value and sync it to URL:

import { useURLSearch } from '@crm/use-url-search-param';

const someRef = ref('value');

// Watch someRef and sync to URL parameter 'key'
useURLSearch('key', () => someRef.value, (val) => val);

API Reference

useURLSearchParam(paramName, defaultValue)

Sync a single URL parameter.

  • paramName: string - The URL parameter name
  • defaultValue: LocationQueryValue | undefined - Default value if not in URL
  • Returns: Ref<LocationQueryValue | undefined> - Reactive ref synchronized with URL

useURLSearchParams(object, options?)

Sync multiple URL parameters.

  • object: T - Default values for parameters
  • options: Options (optional)
    • readFromURLQuery: Function to parse URL values to desired type
    • setURLQuery: Function to format values for URL
  • Returns: Ref<T> - Reactive ref synchronized with URL

useURLSearch(key, reactiveFn, parse)

Watch a reactive value and sync to URL.

  • key: string - The URL parameter name
  • reactiveFn: () => T | undefined - Function that returns the value to watch
  • parse: (val: T) => LocationQueryValue | LocationQueryValue[] - Function to format value for URL

Peer Dependencies

  • vue: ^3.0.0
  • vue-router: ^4.0.0

License

MIT