Skip to content

v0.4.0 - Server Actions Support

Choose a tag to compare

@lance0 lance0 released this 12 Nov 15:13
· 17 commits to master since this release

🎉 Server Actions Support for Next.js 15+

Major new feature release adding first-class support for Next.js 15 Server Actions!

🚀 New Features

Server Actions Helpers:

  • getServerSession(cookieSecret) - Get current session in Server Actions/Components
  • requireAuth(cookieSecret) - Require authentication with helpful errors
  • Full TypeScript support with proper type inference

Example Code:

'use server';

import { requireAuth } from '@lance0/latch';

export async function getProfile() {
  const user = await requireAuth(process.env.LATCH_COOKIE_SECRET!);
  return { name: user.name, email: user.email };
}

📚 Documentation & Examples

  • New Guide: docs/SERVER_ACTIONS.md - Comprehensive patterns and best practices
  • Example Actions:
    • apps/example-app/app/actions/profile.ts - Read operations
    • apps/example-app/app/actions/updateSettings.ts - Mutations & form actions
  • Live Demo: /dashboard/server-actions-demo page with interactive examples
  • README: Updated with Server Actions quick start

🔧 Error Handling

  • New LATCH_UNAUTHORIZED error code
  • Helpful error messages with solutions
  • Clear guidance on handling auth errors in Server Actions

🧪 Tests

  • 7 new tests for Server Actions helpers
  • 142 total tests passing
  • Full coverage of auth scenarios

📊 Roadmap Progress

✅ Completed high-priority item: Server Actions Patterns (15 hours estimated)

This was identified as critical for v1.0 GA and is now complete!

📦 Installation

npm install @lance0/latch@0.4.0

🔄 Migration

Breaking Changes: None
Required Changes: None

This release is 100% backward compatible. New helpers are opt-in additions.

🎯 When to Use

Use Server Actions when:

  • Form submissions and mutations
  • Simple authenticated data fetching
  • Collocated with UI components
  • Want end-to-end TypeScript types

Use API Routes when:

  • OAuth callbacks (like Latch uses)
  • Webhooks from external services
  • Public REST APIs
  • Rate limiting and complex middleware

See the Server Actions guide for detailed decision matrix.

🙏 What's Next

With Server Actions support complete, the next priorities for v1.0 are:

  1. Enhanced validation guards (strict tenant/issuer validation)
  2. Example app presets (commercial vs GCC-High)
  3. Security audit preparation

📖 Learn More


npm: https://www.npmjs.com/package/@lance0/latch