A Vue 3 helper library for developing SoLiD (Social Linked Data) applications with seamless Pinia integration.
Session Management via Pinia Store (useSessionStore)
Session object usage)SessionProvider Component
restorePreviousSession and redirectUrl propsKEYS.SESSION, KEYS.SESSION_INFO, KEYS.LOGIN, and KEYS.LOGOUTimport { useSessionStore } from 'solid-helper-vue';
const sessionStore = useSessionStore();
// Login
await sessionStore.login(identityProvider, redirectUrl, clientName);
// Handle redirect after login (call on every page load)
// Passing window.location.href lets the library detect the OAuth callback params.
// restorePreviousSession: true enables silent re-login on subsequent page loads.
await sessionStore.handleRedirectAfterLogin(window.location.href, true);
// Access session info
if (sessionStore.isLoggedIn) {
console.log(sessionStore.webid); // Current user's WebID
}
// Logout
await sessionStore.logout();
<template>
<!-- restorePreviousSession defaults to true (silent re-login on page load) -->
<!-- redirectUrl defaults to window.location.href at mount time -->
<session-provider>
<your-app />
</session-provider>
</template>
<script setup lang="ts">
import { SessionProvider } from 'solid-helper-vue';
</script>
To opt out of silent re-login, or to specify a fixed callback URL:
<session-provider :restore-previous-session="false" redirect-url="https://myapp.example/callback">
<your-app />
</session-provider>
Inject session data in child components:
import { inject } from 'vue';
import { KEYS } from 'solid-helper-vue';
const session = inject(KEYS.SESSION); // Session object from @inrupt/solid-client-authn-browser
const sessionInfo = inject(KEYS.SESSION_INFO); // Reactive session info
const login = inject(KEYS.LOGIN); // Login function
const logout = inject(KEYS.LOGOUT); // Logout function
Comprehensive test coverage includes:
Unit Tests (src/__tests__)
Integration Tests (through complete apps) (integration-projects/vite-vue-spa)
Run tests:
npm run test # Watch mode
npm run test:run # Single run
npm run test:coverage # Coverage report
npm run test:integration # Playwright integration tests
npm run test:all # All tests
npm install solid-helper-vue
Peer dependencies: Vue 3 and Pinia
Apache-2.0
Generated using TypeDoc