Sh Frontend!
Documentation
Backend Docs
Github
Documentation
Backend Docs
Github
  • Guide

    • Introduction
  • Layouts

    • sh card layout
  • Components

    • ShModal
    • Sh modal Form
    • Sh Canvas
    • Confirmation Action
    • Routes
    • Sh Tabs
    • Sh Dynamic Tabs
    • Sh Form
    • Sh Table
  • Helpers

    • Helpers
    • shUser
    • shApi
    • shRepo
  • About

    • Overview
    • Team

shUser

This is a state management class to manage our logged in user

It uses pinia for state management

Importing

import { useUserStore } from '@iankibetsh/shframework'

const userStore = useUserStore()

You first import the store class then instantiate it to userStore constant

Using it in component

const { user } = storeToRefs(userStore)

Then you can use it in component template this way

<h5>Welcome {{ user.name }}</h5>

Methods

setAccessToken

This is used to set access token for the logged in user.

userStore.setAccessToken(res.token)

setUser | fetchUser

This gets logged in user from the backend and updates user state

userStore.setUser()

logOut | signOut

This removes current session and logs out user. It basically empties accesstoken from locat storage and makes user state null

userStore.logOut()
Last Updated:: 6/27/25, 8:57 AM
Contributors: Hosea Kibet
Prev
Helpers
Next
shApi