@jengo/mreja
v1.0.1
Published
Universal TypeScript full-stack integration toolkit for CodeIgniter 4 and the Jengo Framework ecosystem.
Maintainers
Readme
@jengo/mreja
Universal TypeScript full-stack integration toolkit for CodeIgniter 4 and the Jengo Framework ecosystem.
Provides reactive composables, Ziggy-style named routing, automated user timezone adaptation, live Precognitive validation for Inertia useForm, unified pagination components, Vima RBAC/ABAC authorization guards, instant search, and real-time AI token streaming.
Designed to pair with the Jengo Framework and works seamlessly across React, Vue 3, Svelte, and Vanilla TypeScript.
Installation
# npm
npm install @jengo/mreja
# pnpm
pnpm add @jengo/mreja
# yarn
yarn add @jengo/mrejaFeatures
1. Named Route Resolver (route())
Ziggy-equivalent named routing for CodeIgniter 4 routes registered with ['as' => '...'].
import { route } from '@jengo/mreja/routes';
// Resolve simple route
route('home'); // "/"
// Route with parameters
route('users.show', { id: 42 }); // "/users/42"
// Check current active route for nav link highlighting
route().current('users.*'); // boolean
// Extract parameters from current URL
route().params; // { id: "42" }2. CodeIgniter 4 Time & User Timezone Bridge (useDate(), <FormattedDate />)
Automatically adapts CI4 Time timestamps to the user's browser timezone and locale.
import { useDate } from '@jengo/mreja/vue'; // or @jengo/mreja/react
const { format, fromNow, isPast } = useDate(user.created_at);
format('date'); // "Oct 6, 2026"
fromNow(); // "5 minutes ago" (auto-ticks reactively)// React
import { FormattedDate } from '@jengo/mreja/react';
<FormattedDate value={post.created_at} relative tooltip />3. Live Form Validation for Inertia (withPrecognition)
Enhance native Inertia useForm with server-authoritative field validation on blur/change without triggering controllers or database actions.
import { useForm } from '@inertiajs/vue3';
import { withPrecognition } from '@jengo/mreja/vue'; // or @jengo/mreja/react
const form = withPrecognition(useForm({
username: '',
email: '',
password: '',
}));
// Template binding
<input v-model="form.email" @blur="form.validate('email')" />
<span v-if="form.errors.email">{{ form.errors.email }}</span>4. Unified Pagination (<Pagination />, useInfiniteScroll())
One component supporting both CodeIgniter 4 Pager DTOs and jengo/api pagination envelopes while preserving Inertia state and query filters.
// React
import { Pagination } from '@jengo/mreja/react';
<Pagination meta={users.pager} />// Infinite scroll
import { useInfiniteScroll } from '@jengo/mreja/vue';
const { isFetching } = useInfiniteScroll(posts, {
onFetchNextPage: (page) => router.get(`/posts?page=${page}`, {}, { preserveState: true })
});5. Vima & Auth Client Authorization (useAuth(), can(), requireSudo())
Evaluate Vima RBAC/ABAC permissions and GitHub-style Sudo mode on the frontend.
import { useAuth } from '@jengo/mreja/vue';
const { can, hasRole, isSudoActive, requireSudo } = useAuth();
if (can('posts.edit', post)) {
// User can edit this post
}
// Sudo confirmation trigger
requireSudo(() => {
deleteAccount();
});6. Instant Search (useSearch())
Connect components to jengo/search (Meilisearch, Typesense, MySQL Full-Text) with automatic debouncing, cancellation, and faceting.
import { useSearch } from '@jengo/mreja/react';
const { query, setQuery, results, isSearching, setFilter } = useSearch('/api/v1/search/articles');7. Real-Time AI Token Streaming (useAiStream())
Stream LLM tokens from jengo/ai's ->toSseResponse() endpoints with a single hook.
import { useAiStream } from '@jengo/mreja/vue';
const { stream, isStreaming, send, abort } = useAiStream('/ai/chat');
send('Write an essay on modern PHP');8. Fluent API Query Builder (createApiQuery())
Build query strings adhering to jengo/api resource query parameter conventions.
import { createApiQuery } from '@jengo/mreja/api';
const url = createApiQuery('/api/v1/users')
.page(2)
.limit(20)
.sort('created_at', true)
.search('Alice')
.derive(['profile', 'posts'])
.filter('is_active', true)
.build();
// "/api/v1/users?page=2&limit=20&sort=-created_at&search=Alice&derive=profile,posts&filter[is_active]=true"License
MIT License © Ian Otieno / Jengo Framework.
