Back to Home
qortex-core
Framework Agnostic

qortex-core

A minimal query cache and fetch registry that works everywhere. Set and read data from React, Vue, Svelte, or vanilla JS.

npm install qortex-core

Quick Start

import { registerFetcher, fetchQuery, getQueryData } from 'qortex-core';
// Register a fetcher
registerFetcher('users', async () => {
const res = await fetch('/api/users');
return res.json();
});
// Fetch data (cached automatically)
const users = await fetchQuery('users');
// Read cached data anywhere
const cachedUsers = getQueryData('users');
// Update cache manually
setQueryData('users', newUsers);
// Invalidate to trigger refetch
invalidateQuery('users');

Features

Smart Caching

Automatic deduplication and intelligent cache management

Framework Agnostic

Works in React, Vue, Svelte, or vanilla JavaScript

Background Updates

Stale-while-revalidate pattern built in

TypeScript First

Full type inference and safety

Error Handling

Comprehensive error states and recovery

Persistence

Optional localStorage/sessionStorage persistence

Core APIs

FunctionDescription
registerFetcherRegister a fetch function for a query key
fetchQueryExecute a query and cache the result
getQueryDataRead cached data synchronously
setQueryDataUpdate cached data manually
getQueryStateGet full query state (loading, error, etc.)
invalidateQueryMark query as stale and refetch
subscribeQuerySubscribe to query state changes

Tiny Bundle Size

Lightweight and optimized for performance.

~1.9KBmin + gzip

1.9KB / 10KB Performance Budget

Minified Size5.0KB
Dependencies0
Tree Shaking
Supported

Ready to get started?

npm install qortex-core

Read the Documentation