Orbit Docs
Get Started
Deployment
Architecture
Architecture Overview
Shared Packages
Database
Database Schema
Triggers & Functions
Features
Spaces
Posts
Comments
Follows
Notifications
Feeds
Roles
Roles & Permissions
Api
Admin Api
Users
Roles
Site Configuration
Content Moderation — Posts
Content Moderation — Spaces
Hub Api
Spaces
Posts
Comments
Reactions
Memberships
Follows
Feeds
Uploads
Views
Other Api
Profile
Public Profiles
Notifications
Leaderboard
About
OG Metadata
User Search
Sponsored
Aveiro
aveiro.app
TrademarkTrademark
Ctrl k
Search...
Sign up
Orbit Docs
Get Started
Deployment
Architecture
Architecture Overview
Shared Packages
Database
Database Schema
Triggers & Functions
Features
Spaces
Posts
Comments
Follows
Notifications
Feeds
Roles
Roles & Permissions
Api
Admin Api
Users
Roles
Site Configuration
Content Moderation — Posts
Content Moderation — Spaces
Hub Api
Spaces
Posts
Comments
Reactions
Memberships
Follows
Feeds
Uploads
Views
Other Api
Profile
Public Profiles
Notifications
Leaderboard
About
OG Metadata
User Search
Sponsored
Aveiro
aveiro.app
Sponsored
Aveiro
aveiro.app
Sponsored
Aveiro
aveiro.app
TrademarkTrademark
OrbitSupa Social by Dopler
© Dopler. All rights reserved.
Built with Aveiro

Follows

User-to-user follow system with notifications, stats, and profile integration.
Updated 11d ago
Comments
Notifications
Users can follow other users to stay updated on their activity. The follow system powers follower/following counts, profile hover cards, and post notifications.

How It Works

Following is a one-way relationship stored in the hub_user_follows table. A self-follow constraint prevents users from following themselves.
Action
Method
Description
FollowPOST /api/hub/followsCreates a follow relationship
UnfollowDELETE /api/hub/followsRemoves the follow relationship
Check statusGET /api/hub/followsReturns whether the current user follows a target user
All mutation endpoints require authentication via session cookies.

Optimistic UI

The useFollow hook provides an optimistic toggle experience:
  • The follow/unfollow button updates immediately on click
  • The API request fires in the background
  • On failure, the UI rolls back to the previous state

User Stats

The GET /api/hub/follows endpoint (via getUserStats) returns aggregate counts:
Stat
Description
followersNumber of users following this user
followingNumber of users this user follows
postsNumber of visible posts by this user
These stats are displayed in the ProfileWidget hover card that appears when hovering over a username in feeds, comments, and the leaderboard.

Followers & Following Lists

Paginated endpoints for listing a user's followers and the users they follow:
  • GET /api/hub/followers?userId=...&limit=20&offset=0
  • GET /api/hub/following?userId=...&limit=20&offset=0
Both return profile data (username, slug, avatar, bio) and a hasMore flag for pagination.

Notifications

The follow system triggers two types of notifications via database triggers:
  • new_follower — When user A follows user B, user B receives a notification linking to user A's profile
  • follower_post — When a user publishes a new visible post, all followers are notified with the post title and a direct link
Users who have muted a space are excluded from follower_post notifications for posts in that space.

Profile Integration

Follow buttons appear in:
  • User profile pages (/u/[user])
  • ProfileWidget hover cards (feeds, comments, leaderboard)
  • SpaceWidget hover cards do not show follow buttons (spaces use join/leave instead)

Database

The hub_user_follows table has:
  • A composite primary key on (follower_id, following_id)
  • A self-follow constraint (follower_id <> following_id)
  • Indexes on both follower_id and following_id for efficient lookups
  • RLS enabled with read-only access for authenticated users; mutations go through API routes