Skip to content

Stores & State Management

All state management uses Svelte 5 runes ($state, $derived, $derived.by, $effect) with a Singleton pattern. There are no traditional Svelte stores (writable, readable) in the core stores.

Located in src/lib/stores/:

Current authenticated user state.

File: user-store.svelte.ts

// Usage
import { userStore } from '$lib/stores/user-store.svelte';
userStore.user; // Firebase Auth user
userStore.userData; // Firestore user document (User type)
userStore.referralCode; // User's referral code
userStore.isAuthenticated(); // boolean
userStore.getUserId(); // string | null

User data management and collection access.

File: user-manager.svelte.ts

import { userManager } from '$lib/stores/user-manager.svelte';
userManager.userData; // Current user document data
userManager.allUsers; // Collection of all users
await userManager.updateUser(updates, userId);
userManager.getUserById(userId);

Active subscription data with plan priority logic.

File: subscription-manager.svelte.ts

import { subscriptionManager } from '$lib/stores/subscription-manager.svelte';
subscriptionManager.subscriptionData;
// Returns subscription with priority: Elite > Pro > Standard > Free
// Falls back to Free plan if no active subscription

Subscription shape:

{
metadata: {
planName: 'Elite' | 'Pro' | 'Standard' | 'Free';
price: string;
planStorage: string;
};
current_period_start: Timestamp;
current_period_end: Timestamp;
}

User file storage tracking and limit checking.

File: storage-user-manager.svelte.ts

import { storageUserManager } from '$lib/stores/storage-user-manager.svelte';
storageUserManager.storageData; // Storage usage data
storageUserManager.avatarFileData; // Avatar file record
storageUserManager.bannerFileData; // Banner file record
storageUserManager.logoFileData; // Logo file record
storageUserManager.checkStorageLimit(fileSize); // boolean

Dynamic sidebar routing - maps URL paths to sidebar components.

File: sidebar-manager.svelte.ts

import { sidebarManager } from '$lib/stores/sidebar-manager.svelte';
sidebarManager.currentSidebar; // Returns Svelte component for current path

Product and pricing data from Firestore collection groups.

File: plans-manager.svelte.ts

import { plansManager } from '$lib/stores/plans-manager.svelte';
plansManager.products; // Active products (Standard, Elite)
plansManager.prices; // Active recurring prices
plansManager.isLoading;

User registration system configuration (private beta gating).

File: user-registry-manager.svelte.ts

import { userRegistryManager } from '$lib/stores/user-registry-manager.svelte';
userRegistryManager.currentUserCount;
userRegistryManager.userLimit;
userRegistryManager.isEnabled;
userRegistryManager.hasReachedLimit;
userRegistryManager.canAcceptNewUsers();

Each module has its own stores following the same singleton pattern. Key examples:

ModuleStorePurpose
hubshubsManagerHub CRUD, pages, blocks, docs
hubsteamManagerHub team members and invitations
hubsthemeManagerTheme presets and customization
hubsanalyticsManagerHub visitor analytics
hyvflowworkspaceManagerWorkspaces, portfolios, projects, milestones
hyvflowtaskManagerTask CRUD and activity
connectchatManagerChat conversations and messages
profileprofileManagerUser profile data
profilefollowManagerFollow/follower relationships
marketplacemarketplaceManagerService listings and filtering
ordersordersManagerPurchase and sales orders
dashboarddashboardManagerWidget layout and configuration
blogsblogManagerBlog CRUD operations
refer-and-earnreferralStoreReferral codes and data