--- url: /examples/saas-dashboard.md --- # 📊 SaaS Dashboard Build a complete SaaS platform with team management, API keys, analytics, and billing. ::: info 📖 Cross-Ecosystem Example This is a **complete tutorial** demonstrating the standard Flowfull architecture pattern using **flowfull-node** for your custom SaaS backend. ::: ## 🎯 What You'll Build A production-ready SaaS dashboard with: * ✅ Team management with role-based access * ✅ API key generation and management * ✅ Usage analytics and metrics * ✅ Webhook management * ✅ Team billing and subscriptions * ✅ Activity logs and audit trail * ✅ Admin panel **Time to complete:** ~150 minutes *** ## 🛠️ Tech Stack | Component | Technology | Purpose | |-----------|-----------|---------| | 🔐 **Flowless** | Managed Service (pubflow.com) | Authentication - Team auth, OAuth, roles | | ⚡ **Flowfull** | Node.js (flowfull-node) | **Your custom backend** - Analytics, webhooks, API keys, teams | | 🎨 **Flowfull Clients** | React (@pubflow/react) | **Your frontend** - Dashboard with charts and analytics | | 💳 **Bridge Payments** | Managed Service | Payment processing - Team subscriptions, usage billing | ::: tip 🏗️ Standard Architecture Pattern * **Flowless** = Authentication backend (managed, no code needed) * **Flowfull** = Your custom backend using flowfull-node (you write this) * **Flowfull Clients** = Your frontend using @pubflow/react (you write this) * **Bridge Payments** = Payment backend (managed, API integration only) ::: *** ## 🏗️ Architecture ```mermaid graph TB subgraph "🎨 Your Frontend (React)" A["Team Dashboard
(@pubflow/react)"] B["API Keys Manager
(React Components)"] C["Analytics
(Charts & Metrics)"] D["Billing Portal
(Bridge Payments UI)"] end subgraph "⚡ Your Backend (Flowfull)" E["Analytics API
(flowfull-node)"] F["Webhooks API
(Node.js + Database)"] G["API Keys API
(Custom Business Logic)"] H["Teams API
(Multi-tenant Logic)"] end subgraph "☁️ Pubflow Managed Services" I["🔐 Flowless
(pubflow.com)"] J["💳 Bridge Payments
(Subscription Billing)"] end A -->|"Manage Teams"| H B -->|"Generate Keys"| G C -->|"Track Usage"| E D -->|"Subscribe"| J E -->|"Validate Sessions"| I F -->|"Bridge Validation"| I G -->|"Auth Check"| I H -->|"Auth Check"| I J -->|"Billing Webhooks"| E style A fill:#4CAF50,stroke:#2E7D32,stroke-width:3px,color:#fff style E fill:#2196F3,stroke:#1565C0,stroke-width:3px,color:#fff style I fill:#FF9800,stroke:#E65100,stroke-width:3px,color:#fff style J fill:#9C27B0,stroke:#6A1B9A,stroke-width:3px,color:#fff ``` **Flow:** 1. Frontend (React) → Your Backend (Flowfull/flowfull-node) 2. Your Backend → Flowless for authentication 3. Your Backend → Bridge Payments for subscription billing 4. Bridge Payments → Your Backend (webhooks for billing events) *** ## 📋 Prerequisites * ✅ **Bun** v1.0+ ([Install](https://bun.sh)) or Node.js 18+ * ✅ **Database** - PostgreSQL, MySQL, or LibSQL/Turso * ✅ **Pubflow account** - Sign up at [pubflow.com](https://pubflow.com) * ✅ **Code Editor** - VS Code, Cursor, or your favorite editor * ✅ Basic knowledge of React and TypeScript *** ## 🚀 Step 1: Setup Flowless Authentication (5 min) ### 1.1 Create Flowless Instance 1. Visit [pubflow.com](https://pubflow.com) 2. Sign up or log in 3. Click **"Create Flowless Instance"** 4. Name it: `saas-auth` 5. Copy your **Bridge Secret** Your Flowless URL will be: ``` https://saas-auth.pubflow.com ``` ::: tip 📖 Learn More For detailed Flowless setup, see [Flowless Getting Started](https://flowless.dev/getting-started) ::: *** ## ⚡ Step 2: Setup Flowfull Backend (10 min) ### 2.1 Clone flowfull-node (Official Starter Kit) ::: tip 📦 Official Starter Kit **flowfull-node** is the official, production-ready starter kit maintained by the Pubflow team. [View Documentation →](https://flowfull.dev/getting-started) ::: ```bash # Clone the official flowfull-node template git clone https://github.com/pubflow/flowfull-node.git saas-backend cd saas-backend # Install dependencies bun install # or: npm install ``` ### 2.2 Configure Environment Variables Copy the example environment file: ```bash cp .env.example .env ``` Edit `.env` with your configuration: ```env # Flowless Configuration FLOWLESS_API_URL=https://saas-auth.pubflow.com BRIDGE_VALIDATION_SECRET=your_bridge_secret_here # Database DATABASE_URL=postgresql://user:pass@localhost:5432/saas # Server PORT=3001 NODE_ENV=development # Optional: Cache REDIS_URL=redis://localhost:6379 ``` ::: info 🔧 Environment Variables * `FLOWLESS_API_URL`: Your Flowless instance URL from Step 1 * `BRIDGE_VALIDATION_SECRET`: Bridge secret from Pubflow dashboard * `DATABASE_URL`: Your PostgreSQL/MySQL/LibSQL connection string ::: *** ## 📊 Step 3: Database Schema ```sql -- Teams CREATE TABLE teams ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), name VARCHAR(255) NOT NULL, owner_id VARCHAR(255) NOT NULL, plan VARCHAR(50) DEFAULT 'free', created_at TIMESTAMP DEFAULT NOW() ); -- Team Members CREATE TABLE team_members ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), team_id UUID REFERENCES teams(id) ON DELETE CASCADE, user_id VARCHAR(255) NOT NULL, role VARCHAR(50) DEFAULT 'member', created_at TIMESTAMP DEFAULT NOW(), UNIQUE(team_id, user_id) ); -- API Keys CREATE TABLE api_keys ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), team_id UUID REFERENCES teams(id) ON DELETE CASCADE, name VARCHAR(255) NOT NULL, key_hash VARCHAR(255) NOT NULL, prefix VARCHAR(20) NOT NULL, last_used_at TIMESTAMP, created_at TIMESTAMP DEFAULT NOW() ); -- Webhooks CREATE TABLE webhooks ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), team_id UUID REFERENCES teams(id) ON DELETE CASCADE, url VARCHAR(1000) NOT NULL, events JSONB DEFAULT '[]', secret VARCHAR(255) NOT NULL, active BOOLEAN DEFAULT true, created_at TIMESTAMP DEFAULT NOW() ); -- Analytics Events CREATE TABLE analytics_events ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), team_id UUID REFERENCES teams(id) ON DELETE CASCADE, event_type VARCHAR(100) NOT NULL, metadata JSONB, created_at TIMESTAMP DEFAULT NOW() ); -- Usage Metrics CREATE TABLE usage_metrics ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), team_id UUID REFERENCES teams(id) ON DELETE CASCADE, metric_type VARCHAR(100) NOT NULL, value INTEGER NOT NULL, period DATE NOT NULL, created_at TIMESTAMP DEFAULT NOW() ); ``` *** ## ⚡ Step 1: Team Management API ```typescript // src/routes/teams.ts import { Hono } from 'hono' import { validateSession } from '../middleware/auth' const teams = new Hono() // Create team teams.post('/', validateSession, async (c) => { const user = c.get('user') const { name } = await c.req.json() const team = await db .insertInto('teams') .values({ name, owner_id: user.id, plan: 'free' }) .returningAll() .executeTakeFirst() // Add owner as admin await db .insertInto('team_members') .values({ team_id: team.id, user_id: user.id, role: 'admin' }) .execute() return c.json({ team }, 201) }) // Get team members teams.get('/:teamId/members', validateSession, async (c) => { const teamId = c.req.param('teamId') const members = await db .selectFrom('team_members') .selectAll() .where('team_id', '=', teamId) .execute() return c.json({ members }) }) // Invite member teams.post('/:teamId/invite', validateSession, async (c) => { const teamId = c.req.param('teamId') const { email, role } = await c.req.json() // Send invitation email // Add to team_members when accepted return c.json({ success: true }) }) ``` *** ## 🔑 Step 2: API Keys Management ```typescript // src/routes/api-keys.ts import { Hono } from 'hono' import { createHash, randomBytes } from 'crypto' const apiKeys = new Hono() // Generate API key apiKeys.post('/', validateSession, async (c) => { const user = c.get('user') const { team_id, name } = await c.req.json() // Generate key const key = `sk_${randomBytes(32).toString('hex')}` const keyHash = createHash('sha256').update(key).digest('hex') const prefix = key.substring(0, 12) const apiKey = await db .insertInto('api_keys') .values({ team_id, name, key_hash: keyHash, prefix }) .returningAll() .executeTakeFirst() // Return full key only once return c.json({ api_key: { ...apiKey, key } }, 201) }) // List API keys apiKeys.get('/team/:teamId', validateSession, async (c) => { const teamId = c.req.param('teamId') const keys = await db .selectFrom('api_keys') .select(['id', 'name', 'prefix', 'last_used_at', 'created_at']) .where('team_id', '=', teamId) .execute() return c.json({ keys }) }) ``` *** ## 📊 Step 3: Analytics Dashboard ```tsx // src/pages/analytics.tsx import { useBridge } from '@pubflow/react' import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip } from 'recharts' export default function AnalyticsPage() { const { data: metrics } = useBridge('/analytics/metrics?period=7d') return (

Analytics

API Calls

{metrics?.api_calls || 0}

+12% from last week

Active Users

{metrics?.active_users || 0}

+8% from last week

Success Rate

{metrics?.success_rate || 0}%

Last 7 days

API Usage

) } ``` *** ## 💳 Step 4: Team Billing ```tsx // src/pages/billing.tsx import { useState } from 'react' import { useAuth } from '@pubflow/react' export default function BillingPage() { const { user } = useAuth() const [loading, setLoading] = useState(false) const plans = [ { name: 'Free', price: 0, calls: 1000 }, { name: 'Pro', price: 29, calls: 100000 }, { name: 'Enterprise', price: 299, calls: 'Unlimited' } ] const handleUpgrade = async (plan: string) => { setLoading(true) const response = await fetch('/api/billing/subscribe', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Session-Id': localStorage.getItem('pubflow_session_id') || '' }, body: JSON.stringify({ plan }) }) const { client_secret } = await response.json() window.location.href = `https://checkout.stripe.com/${client_secret}` } return (

Billing

{plans.map((plan) => (

{plan.name}

${plan.price}/mo

{plan.calls} API calls/month

))}
) } ``` *** ## 🎉 Result You've built a complete SaaS dashboard with: * ✅ Team management * ✅ API key generation * ✅ Analytics dashboard * ✅ Billing integration *** ## 📖 Next Steps * 🔔 **Notifications** - Real-time alerts * 📧 **Email reports** - Weekly summaries * 🔒 **2FA** - Enhanced security * 📱 **Mobile app** - iOS/Android dashboard *** ## 📚 Related Resources * 🔐 **[Flowless Documentation](/)** - Authentication * ⚡ **[Flowfull Documentation](https://flowfull.dev)** - Backend * 💳 **[Bridge Payments](https://bridgepayments.dev)** - Billing * 💬 **[Discord](https://discord.gg/EJfPTT6Vh7)** - Community --- --- url: /examples/full-stack-blog.md --- # 📝 Full-Stack Blog App Build a complete blog application with authentication, posts, comments, and premium subscriptions. ::: info 📖 Cross-Ecosystem Example This is a **complete tutorial** showing how to build a full-stack application using the Pubflow ecosystem. It demonstrates the standard Flowfull architecture pattern using **flowfull-node** for the backend. ::: ## 🎯 What You'll Build A production-ready blog platform with: * ✅ User authentication (register, login, logout) * ✅ Create, edit, and delete blog posts * ✅ Comments system with nested replies * ✅ Premium subscriptions ($9.99/month) * ✅ Admin dashboard for content moderation * ✅ Rich text editor with image uploads * ✅ SEO-optimized with meta tags * ✅ Responsive design (mobile + desktop) **Time to complete:** ~90 minutes *** ## 🛠️ Tech Stack This example demonstrates the complete Pubflow ecosystem: | Component | Technology | Purpose | |-----------|-----------|---------| | 🔐 **Flowless** | Managed Service (pubflow.com) | Authentication backend - handles user registration, login, sessions, OAuth | | ⚡ **Flowfull** | Node.js (flowfull-node) | **Your custom backend** with business logic - Posts CRUD, comments, user profiles | | 🎨 **Flowfull Clients** | React (@pubflow/react) | **Your frontend** - React components, hooks, routing | | 💳 **Bridge Payments** | Managed Service (optional) | Payment processing - Monthly billing, payment methods | ::: tip 🏗️ Standard Architecture Pattern * **Flowless** = Authentication backend (managed, no code needed) * **Flowfull** = Your custom backend using flowfull-node (you write this) * **Flowfull Clients** = Your frontend using @pubflow/react (you write this) ::: *** ## 🏗️ Architecture ```mermaid graph TB subgraph "🎨 Your Frontend (React)" A["Blog UI
(Flowfull Clients)"] B["Post Editor
(@pubflow/react)"] C["Comments Section
(React Components)"] D["Subscription Portal
(Bridge Payments UI)"] end subgraph "⚡ Your Backend (Flowfull)" E["Posts API
(flowfull-node)"] F["Comments API
(Node.js + Express/Hono)"] G["User Profiles API
(Custom Business Logic)"] end subgraph "☁️ Pubflow Managed Services" H["🔐 Flowless
(pubflow.com)"] I["💳 Bridge Payments
(Optional)"] end A -->|"API Requests"| E B -->|"Create/Edit Posts"| E C -->|"Post Comments"| F D -->|"Subscribe"| I E -->|"Validate Sessions"| H F -->|"Bridge Validation"| H G -->|"Auth Check"| H style A fill:#4CAF50,stroke:#2E7D32,stroke-width:3px,color:#fff style E fill:#2196F3,stroke:#1565C0,stroke-width:3px,color:#fff style H fill:#FF9800,stroke:#E65100,stroke-width:3px,color:#fff style I fill:#9C27B0,stroke:#6A1B9A,stroke-width:3px,color:#fff ``` **Flow:** 1. Frontend (React) → Your Backend (Flowfull/flowfull-node) 2. Your Backend → Flowless (pubflow.com) for session validation 3. Flowless → Your Backend (Trust Token with user data) 4. Your Backend → Frontend (Protected data) *** ## 📋 Prerequisites Before starting, make sure you have: * ✅ **Bun** v1.0+ ([Install](https://bun.sh)) or Node.js 18+ * ✅ **Database** - PostgreSQL, MySQL, or LibSQL/Turso * ✅ **Pubflow account** - Sign up at [pubflow.com](https://pubflow.com) * ✅ **Code Editor** - VS Code, Cursor, or your favorite editor * ✅ Basic knowledge of React and TypeScript *** ## 🚀 Step 1: Setup Flowless Authentication (5 min) ### 1.1 Create Flowless Instance 1. Visit [pubflow.com](https://pubflow.com) 2. Sign up or log in 3. Click **"Create Flowless Instance"** 4. Name it: `blog-auth` 5. Copy your **Bridge Secret** (you'll need this later) Your Flowless URL will be: ``` https://blog-auth.pubflow.com ``` ### 1.2 Configure Email Templates (Optional) Enable email verification and password reset: 1. Go to Instance Settings → Email 2. Enable "Email Verification" 3. Enable "Password Reset" 4. Customize email templates (optional) ::: tip 📖 Learn More For detailed Flowless setup, see [Flowless Getting Started](https://flowless.dev/getting-started) ::: ### 1.3 Test Authentication Use the [API Playground](/playground) to test: ```bash # Register a test user curl -X POST https://your-instance.pubflow.com/auth/register \ -H "Content-Type: application/json" \ -d '{ "email": "test@example.com", "password": "SecurePass123!", "name": "Test User" }' ``` ✅ **Checkpoint:** You should receive a session\_id in the response. *** ## ⚡ Step 2: Build Flowfull Backend (30 min) ### 2.1 Clone flowfull-node (Official Starter Kit) ::: tip 📦 Official Starter Kit **flowfull-node** is the official, production-ready starter kit maintained by the Pubflow team. It includes all core features, best practices, and is regularly updated. [View Documentation →](https://flowfull.dev/getting-started) ::: ```bash # Clone the official flowfull-node template git clone https://github.com/pubflow/flowfull-node.git blog-backend cd blog-backend # Install dependencies bun install # or: npm install ``` ### 2.2 Configure Environment Variables Copy the example environment file: ```bash cp .env.example .env ``` Edit `.env` with your configuration: ```env # Flowless Configuration FLOWLESS_API_URL=https://blog-auth.pubflow.com BRIDGE_VALIDATION_SECRET=your_bridge_secret_here # Database DATABASE_URL=postgresql://user:pass@localhost:5432/blog # Server PORT=3001 NODE_ENV=development # Optional: Cache (for better performance) REDIS_URL=redis://localhost:6379 ``` ::: info 🔧 Environment Variables * `FLOWLESS_API_URL`: Your Flowless instance URL from Step 1 * `BRIDGE_VALIDATION_SECRET`: Bridge secret from Pubflow dashboard * `DATABASE_URL`: Your PostgreSQL/MySQL/LibSQL connection string ::: ### 2.3 Create Database Schema Create `schema.sql`: ```sql -- Posts table CREATE TABLE posts ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), user_id VARCHAR(255) NOT NULL, title VARCHAR(500) NOT NULL, slug VARCHAR(500) UNIQUE NOT NULL, content TEXT NOT NULL, excerpt TEXT, cover_image VARCHAR(1000), published BOOLEAN DEFAULT false, premium_only BOOLEAN DEFAULT false, created_at TIMESTAMP DEFAULT NOW(), updated_at TIMESTAMP DEFAULT NOW() ); -- Comments table CREATE TABLE comments ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), post_id UUID REFERENCES posts(id) ON DELETE CASCADE, user_id VARCHAR(255) NOT NULL, parent_id UUID REFERENCES comments(id) ON DELETE CASCADE, content TEXT NOT NULL, created_at TIMESTAMP DEFAULT NOW() ); -- Indexes for performance CREATE INDEX IF NOT EXIST idx_posts_user_id ON posts(user_id); CREATE INDEX IF NOT EXIST idx_posts_slug ON posts(slug); CREATE INDEX IF NOT EXIST idx_comments_post_id ON comments(post_id); CREATE INDEX IF NOT EXIST idx_comments_parent_id ON comments(parent_id); ``` Run migrations: ```bash psql $DATABASE_URL < schema.sql ``` ### 2.4 Implement Posts API Create `src/routes/posts.ts`: ```typescript import { Hono } from 'hono' import { validateSession } from '../middleware/auth' import { db } from '../db' const posts = new Hono() // Get all posts (public) posts.get('/', async (c) => { const posts = await db .selectFrom('posts') .selectAll() .where('published', '=', true) .orderBy('created_at', 'desc') .execute() return c.json({ posts }) }) // Get single post by slug posts.get('/:slug', async (c) => { const slug = c.req.param('slug') const post = await db .selectFrom('posts') .selectAll() .where('slug', '=', slug) .where('published', '=', true) .executeTakeFirst() if (!post) { return c.json({ error: 'Post not found' }, 404) } return c.json({ post }) }) // Create post (authenticated) posts.post('/', validateSession, async (c) => { const user = c.get('user') const { title, content, excerpt, cover_image, premium_only } = await c.req.json() // Generate slug from title const slug = title.toLowerCase() .replace(/[^a-z0-9]+/g, '-') .replace(/(^-|-$)/g, '') const post = await db .insertInto('posts') .values({ user_id: user.id, title, slug, content, excerpt, cover_image, premium_only: premium_only || false, published: false }) .returningAll() .executeTakeFirst() return c.json({ post }, 201) }) // Update post (authenticated, owner only) posts.put('/:id', validateSession, async (c) => { const user = c.get('user') const id = c.req.param('id') const { title, content, excerpt, cover_image, published, premium_only } = await c.req.json() // Check ownership const existing = await db .selectFrom('posts') .select('user_id') .where('id', '=', id) .executeTakeFirst() if (!existing || existing.user_id !== user.id) { return c.json({ error: 'Unauthorized' }, 403) } const post = await db .updateTable('posts') .set({ title, content, excerpt, cover_image, published, premium_only, updated_at: new Date() }) .where('id', '=', id) .returningAll() .executeTakeFirst() return c.json({ post }) }) // Delete post (authenticated, owner only) posts.delete('/:id', validateSession, async (c) => { const user = c.get('user') const id = c.req.param('id') const existing = await db .selectFrom('posts') .select('user_id') .where('id', '=', id) .executeTakeFirst() if (!existing || existing.user_id !== user.id) { return c.json({ error: 'Unauthorized' }, 403) } await db .deleteFrom('posts') .where('id', '=', id) .execute() return c.json({ success: true }) }) export default posts ``` ### 2.5 Implement Comments API Create `src/routes/comments.ts`: ```typescript import { Hono } from 'hono' import { validateSession } from '../middleware/auth' import { db } from '../db' const comments = new Hono() // Get comments for a post comments.get('/post/:postId', async (c) => { const postId = c.req.param('postId') const comments = await db .selectFrom('comments') .selectAll() .where('post_id', '=', postId) .orderBy('created_at', 'asc') .execute() return c.json({ comments }) }) // Create comment (authenticated) comments.post('/', validateSession, async (c) => { const user = c.get('user') const { post_id, parent_id, content } = await c.req.json() const comment = await db .insertInto('comments') .values({ post_id, parent_id: parent_id || null, user_id: user.id, content }) .returningAll() .executeTakeFirst() return c.json({ comment }, 201) }) // Delete comment (authenticated, owner only) comments.delete('/:id', validateSession, async (c) => { const user = c.get('user') const id = c.req.param('id') const existing = await db .selectFrom('comments') .select('user_id') .where('id', '=', id) .executeTakeFirst() if (!existing || existing.user_id !== user.id) { return c.json({ error: 'Unauthorized' }, 403) } await db .deleteFrom('comments') .where('id', '=', id) .execute() return c.json({ success: true }) }) export default comments ``` ✅ **Checkpoint:** Test your APIs with curl or Postman. *** ## Step 3: Create React Frontend (40 min) ### 3.1 Clone react-flowfull-client (TanStack Start Starter Kit) ::: tip Official Frontend Starter This tutorial continues with **react-flowfull-client**, the official React starter kit with TanStack Start and `@pubflow/react`. If you want a Next.js app instead, use **next-flowfull-client** and follow the Next.js examples because the routing and file structure are different. [View Documentation](https://clients.flowfull.dev/starter-kits) ::: ```bash # Clone the official React + TanStack Start starter kit git clone https://github.com/pubflow/react-flowfull-client.git blog-frontend cd blog-frontend # Install dependencies npm install # or: bun install ``` ### 3.2 Configure Environment Copy the example environment file: ```bash cp .env.example .env.local ``` Edit `.env.local` with your backend URL: ```env # API Configuration VITE_API_BASE_URL=http://localhost:3001 VITE_BRIDGE_BASE_PATH=/bridge VITE_AUTH_BASE_PATH=/auth # Branding Configuration (Optional) VITE_APP_NAME=My Blog VITE_APP_LOGO=https://your-domain.com/logo.png VITE_PRIMARY_COLOR=#006aff VITE_SECONDARY_COLOR=#4a90e2 ``` ::: info 🔧 Environment Variables * `VITE_API_BASE_URL`: Your Flowfull backend URL (from Step 2) * `VITE_BRIDGE_BASE_PATH`: Bridge API path (default: `/bridge`) * `VITE_AUTH_BASE_PATH`: Auth API path (default: `/auth`) ::: ### 3.3 Create Blog Post List Create `src/pages/blog.tsx`: ```tsx import { useBridge } from '@pubflow/react' import { Link } from '@tanstack/react-router' export default function BlogPage() { const { data: posts, loading } = useBridge('/posts') if (loading) return
Loading...
return (

Blog

{posts?.map((post: any) => (
{post.cover_image && ( {post.title} )}

{post.title}

{post.excerpt}

{new Date(post.created_at).toLocaleDateString()} {post.premium_only && ( Premium )}
))}
) } ``` ### 3.4 Create Post Editor Create `src/pages/editor.tsx`: ```tsx import { useState } from 'react' import { useBridge, useAuth } from '@pubflow/react' import { useNavigate } from '@tanstack/react-router' export default function EditorPage() { const { user } = useAuth() const navigate = useNavigate() const [title, setTitle] = useState('') const [content, setContent] = useState('') const [excerpt, setExcerpt] = useState('') const [premiumOnly, setPremiumOnly] = useState(false) const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() const response = await fetch(`${import.meta.env.VITE_BRIDGE_URL}/posts`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Session-Id': localStorage.getItem('pubflow_session_id') || '' }, body: JSON.stringify({ title, content, excerpt, premium_only: premiumOnly }) }) if (response.ok) { const { post } = await response.json() navigate({ to: `/blog/${post.slug}` }) } } if (!user) { return
Please login to create posts
} return (

Create New Post

setTitle(e.target.value)} className="w-full border rounded px-4 py-2" required />