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

@aaronbushnell/alpinejs-history

v1.0.7

Published

Alpine.js plugin to persist state in the URL query string with browser history traversal (supports objects via bracket params).

Readme

alpinejs-history

Persist Alpine.js state in the URL query string with browser history support.

This plugin lets you bind Alpine state to the URL so:

  • state is shareable via links
  • Back/Forward buttons rehydrate UI state
  • text input doesn’t spam browser history
  • complex objects use conventional bracketed query params

Designed to feel like @alpinejs/persist.


Install

npm install @aaronbushnell/alpinejs-history

Setup

import Alpine from "alpinejs"
import history from "@aaronbushnell/alpinejs-history"

Alpine.plugin(history)
Alpine.start()

Basic usage

<div x-data="{ open: $history(false).as('open') }">
<button @click="open = !open">Toggle</button>

<div x-show="open" x-cloak>
hello
</div>
</div>

URL output

?open=true
?open=false
  • Booleans and numbers use pushState
  • Back/Forward buttons traverse state correctly

Text input (debounced)

<div x-data="{ query: $history(null).as('query') }">
<input x-model="query" placeholder="Search…" />
</div>

URL output

?query=hello+world
  • Writes are debounced
  • Uses replaceState to avoid history spam while typing
  • Back/Forward rehydrates state without page reload

Objects and forms

<div
x-data="{
form: $history({
  name: '',
  email: ''
}).as('form')
}"
>
<input x-model="form.name" placeholder="Name" />
<input x-model="form.email" placeholder="Email" />
</div>

URL output

?form[name]=Aaron&form[email][email protected]
  • Uses conventional bracketed query params
  • Nested objects and arrays are supported
  • Rehydrates cleanly on reload or history navigation

Aliases

open: $history(false).as('menu')
?menu=true

Aliases work the same way as @alpinejs/persist.


History behavior

| Value type | History method | Notes | | --- | --- | --- | | Boolean / Number | pushState | Traversable with Back/Forward | | String | replaceState | Debounced (typing-friendly) | | Object / Array | replaceState | Debounced form editing |


Security notes

  • URL values are untrusted input
  • Avoid rendering $history() values with x-html unless sanitized
  • This plugin blocks __proto__, constructor, and prototype keys to reduce prototype pollution risks

Compatibility

  • Alpine.js v3+
  • ESM-only package (no bundler required)
  • Works with Vite, Webpack, Rollup, etc.

License

MIT