@iankibetsh/sh-core

Core JS layer for sh frameworks: API client, auth (bearer/cookie strategies), pinia stores, streamline, swal notifications and helpers. UI-library free.
1,203
Install
npm install @iankibetsh/sh-core
Latest Version:1.0.3
Vue:3
License:ISC
Last Updated:Sep 22, 2026
Links: npm
Maintainer: iankibetsh

@iankibetsh/sh-core

Core JS layer for the sh frameworks family. UI-library free (no Bootstrap, no Tailwind) — only sweetalert2 for notifications/dialogs. UI packages layer on top:

  • @iankibetsh/shframework (v6+) — Bootstrap 5 components (ShTable, ShForm, ...)
  • @iankibetsh/sh-tailwind (planned) — Tailwind components

What's inside

  • API client — single axios instance with request/response interceptors, configurable free (public) endpoints and central 401 handling. shApis.doGet/doPost/doPut/doPatch/doDelete keep the classic signatures.
  • Auth strategies —
    • bearer (default): token kept in memory + sessionStorage (tokenStorage: 'memory' | 'session' | 'local'). Existing v5 tokens in localStorage are migrated automatically on first request.
    • cookie: Laravel Sanctum SPA mode — httpOnly session cookie set by the server, automatic CSRF (sanctum/csrf-cookie), withCredentials. No token ever stored in JS.
  • useAuth() composable — login, logout, fetchUser, isAllowedTo, user.
  • Pinia stores — useUserStore (id user-store), useAppStore (id sh-app).
  • Streamline — useStreamline, getActionUrl and the IndexedDB cache, built in (successor of @iankibetsh/vue-streamline). Auth rides on the shared client; no manual headers needed.
  • Notifications — swalSuccess, swalError, swalHttpError, showToast, confirmAction, runPlainRequest.
  • Helpers — shRepo aggregate, shStorage, formatDate/formatNumber, session timeout handling, v-if-user-can directive.

Install

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { ShCore } from '@iankibetsh/sh-core'

const app = createApp(App)
app.use(createPinia())
app.use(ShCore, {
    baseApiUrl: import.meta.env.VITE_APP_API_URL,
    authMode: 'bearer',        // or 'cookie' for Sanctum SPA
    tokenStorage: 'session',   // 'memory' | 'session' | 'local'
    sessionTimeout: 400,       // minutes
    loginUrl: '/sh-auth',
    streamlineUrl: '/api/streamline',
    enableCache: true
})

Cookie (Sanctum SPA) mode

app.use(ShCore, {
    baseApiUrl: 'https://api.example.test',
    authMode: 'cookie',
    csrfEndpoint: 'sanctum/csrf-cookie'
})

Backend requirements: SANCTUM_STATEFUL_DOMAINS includes the SPA host, session driver configured and supports_credentials: true in CORS config.

Migration notes (from shframework v5 core)

  • Tokens move from localStorage access_token to sessionStorage (auto-migrated). sessionStorage is per-tab; pass tokenStorage: 'local' if you need multi-tab continuity.
  • doDelete(endpoint, data) now correctly sends data as the request body.
  • Session timer no longer starts on import; it starts when the plugin receives sessionTimeout or after login().

Related Packages

laravel-elixir-vue-2

'Laravel Elixir Vue 2.0 Integration'

28,012 107
vue-tilt.js

Add tilt-effect to your elements

22,943 52
@enso-ui/auth

Authentication pages, auth store helpers, and password-strength utilities for En...

11,552 0
lukk-nuxt

Nuxt module for lukk (first-party Laravel JWT auth) + useLukkFetch, an auth-awar...

2,402 0
nuxt-bearer-auth

Reusable Nuxt authentication module for bearer-token APIs with Redis sessions an...

1,593 0

Version History

Version Released Vue License
1.0.3 ^3.5 ISC
1.0.2 ^3.5 ISC
1.0.1 ^3.5 ISC
1.0.0 ^3.5 ISC