Skip to content

Getting started

Terminal window
npm i @qubeejs/core

Requires Node ^22.12 || ^24 || >=26 for development. The published package targets ES2022 and ships both ESM and CommonJS.

createQubee() wires up the three objects you need and returns them sharing one store.

articles.ts
import { createQubee, STRAPI_DRIVER, SortEnum } from '@qubeejs/core';
const { builder, paginator, store } = createQubee({ driver: STRAPI_DRIVER });
const uri = builder
.setResource('articles')
.addFilter('status', 'published')
.addSort('createdAt', SortEnum.DESC)
.setLimit(25)
.generateUri();

generateUri() is synchronous and returns a string:

/articles?filters[status][$eq]=published&sort[0]=createdAt:desc&pagination[page]=1&pagination[pageSize]=25

qubee does not make the request. Prefix the URI with your API base and use whatever client you like.

const body = await fetch(`https://example.com/api${uri}`).then((r) => r.json());

Hand the body to the paginator. It parses the envelope and syncs the page metadata into the shared store, so navigation helpers know where they are.

const page = paginator.paginate(body);
page.data; // rows
page.total; // 57
page.lastPage; // 6

createQubee() is a convenience, not a requirement. Construct the three yourself when they should not share a store, or when you are wiring them into a framework’s DI container:

import { QubeeStore, QueryBuilder, Paginator, STRAPI_DRIVER } from '@qubeejs/core';
const store = new QubeeStore();
const builder = new QueryBuilder(store, STRAPI_DRIVER.createRequestStrategy('query'));
const paginator = new Paginator(
store,
STRAPI_DRIVER.createResponseStrategy(),
STRAPI_DRIVER.createResponseOptions({}),
);

Import the one you need. The other seventeen tree-shake away, which is the difference between 2.5 kB and 9.5 kB gzipped.

import { STRAPI_DRIVER } from '@qubeejs/core'; // just this driver
import { DRIVERS } from '@qubeejs/core'; // all eighteen

createQubee() deliberately takes a definition, not an id, so it never reaches into the registry on your behalf. Choosing at runtime is still one line — you just opt into the cost explicitly, at your own import site:

import { createQubee, DRIVERS } from '@qubeejs/core';
const { builder } = createQubee({ driver: DRIVERS[config.driver] });