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

aurelia2-query

v0.1.0

Published

Query/caching utilities for Aurelia 2

Readme

aurelia2-query

A lightweight query + caching plugin for Aurelia 2. It provides:

  • a .query binding command
  • a query binding behavior (& query)
  • a headless <au-query> custom element
  • a singleton QueryClient for cache + fetch orchestration

Install

npm install aurelia2-query

Register

import { AureliaQueryConfiguration } from 'aurelia2-query';

Aurelia.register(AureliaQueryConfiguration);

Quick start (headless element)

<au-query query.bind="userQuery" result.bind="result">
  <div if.bind="result.loading">Loading...</div>
  <div if.bind="result.error">Something went wrong.</div>
  <pre if.bind="result.data">${result.data}</pre>
</au-query>
export class Page {
  userId = 42;

  get userQuery() {
    return {
      key: ['user', this.userId],
      fetch: () => api.user(this.userId),
      staleTime: 60_000,
    };
  }

  result = null;
}

Query options

A query definition can be either a function or a full options object.

import type { QueryOptions } from 'aurelia2-query';

const options: QueryOptions<User> = {
  key: ['user', userId],
  fetch: () => api.user(userId),
  enabled: true,
  staleTime: 60_000,
  cacheTime: 5 * 60_000,
};
  • key: string | readonly unknown[] used for caching.
  • fetch: async or sync function returning data.
  • enabled: when false, no fetch happens until refetch().
  • staleTime: how long data is considered fresh (ms).
  • cacheTime: how long unused cache entries survive (ms).

If you pass a function as the query definition, the key defaults to the function name (or "query" if unnamed).

.query binding command

Use this on any bindable to create and assign a QueryResult while binding a query definition.

<result-host result.query="query"></result-host>
class App {
  query = { key: ['users'], fetch: () => api.users() };
}

You can also bind an inline object:

<div result.query="{ key: ['users', page], fetch: () => api.users(page) }"></div>

Under the hood this uses the query binding behavior.

& query binding behavior

If you prefer explicit behavior usage:

<div result.bind="queryDef & query"></div>

<au-query> custom element

<au-query> is a headless element that simply creates a QueryResult and manages the query lifecycle. Use it when you want a dedicated place to declare query state.

Bindings:

  • query.bind (primary): a query definition
  • result.bind: the QueryResult instance (auto-created if omitted)

QueryResult

A QueryResult instance exposes:

  • data, error, status, loading, stale, updatedAt
  • refetch() to force a new fetch
  • invalidate() to mark cache stale

QueryClient

Inject the client if you need manual control:

import { IQueryClient } from 'aurelia2-query';

export class Example {
  constructor(@IQueryClient private readonly client) {}
}

Key methods:

  • fetch(entry, options, force?)
  • invalidate(key)
  • getEntry(key) / getOrCreateEntry(key, options)

Notes

  • Keys are hashed via stable JSON stringification. Object keys are sorted to keep hashes deterministic.
  • When enabled: false, the query is created but does not fetch until refetch().