Logic Lab (Hooks)Overview

Logic Lab (Hooks & Custom Logic)

The Logic Lab is Aerostack’s integrated development environment for the edge. It allows you to intercept any request, add custom business rules, and extend the platform’s core modules (Auth, E-commerce) without managing your own servers.

Core Concepts

In Aerostack, custom logic is implemented as Hooks. These are edge-native functions that run within our high-performance runtime, pre-wired with the Unified SDK.

1. Lifecycle Hooks

These hooks run at specific moments in the request/response lifecycle of pre-built modules.

  • Example: beforeSignup — Validate the user’s email domain before creating the account.
  • Example: afterOrder — Trigger a loyalty point calculation after a successful purchase.

2. Custom API Endpoints

Create entirely new endpoints that leverage Aerostack’s infrastructure.

  • Path: https://<project>.aerostack.dev/api/v1/custom/<your-endpoint>
  • Use Case: Building a custom search index or a specialized reporting tool.

The Unified SDK in Hooks

Every hook receives a pre-authenticated sdk object. This is the exact same SDK you use in your project, ensuring a consistent developer experience across the board.

PrimitiveSDK CallWhy use it in Hooks?
Databasesdk.db.query()Perform cross-table joins or custom data validation.
Cachesdk.cache.set()Store computed results at the edge for sub-millisecond lookups.
Queuesdk.queue.enqueue()Offload heavy tasks (like Slack notifications) to background workers.
AIsdk.ai.chat()Use LLMs to categorize user input or summarize data in real-time.

Workflow: From Idea to Production

1. Develop

Use the built-in Monaco editor with full TypeScript support and AI assistance.

2. Test

Run dry-run tests with mock payloads directly in the browser or via CLI.

3. Deploy

Push your logic to the global network in under 1 second. No build pipelines required.

4. Monitor

Trace every execution through our built-in logs and performance dashboard.


Creating Your First Hook

  1. Navigate to Logic Lab in the Admin Panel.
  2. Select an event (e.g., auth.register.before).
  3. Write your logic using the sdk.
  4. Test with a sample payload.
  5. Click Deploy.

View CLI Deployment Guide →