Skip to Content
ArchitectureFrontend Stack

Frontend Stack

IOTA SDK uses a modern, lightweight frontend stack focused on server-rendered HTML with progressive enhancement.

Stack Overview

Technology Choices

TechnologyPurposeWhy
TemplHTML templatingType-safe, Go-native
HTMXAJAX via HTMLMinimal JS, progressive enhancement
Alpine.jsReactivityLightweight, declarative
Tailwind CSSStylingUtility-first, rapid development

Request/Response Flow

Standard Page Load

HTMX Request

Templ

Type-Safe Templates

Templ provides compile-time type safety for HTML templates:

Benefits:

  • Catch errors at compile time, not runtime
  • IDE support and autocomplete
  • No template parsing overhead
  • Type-safe data passing

Template Structure

Template Types

TypeExtensionPurpose
Pages*.templFull page templates
Components*.templReusable UI components
Layouts*.templPage wrappers
Partials*.templHTMX fragments

HTMX

Progressive Enhancement

HTMX adds AJAX functionality via HTML attributes:

Key Attributes

AttributePurposeExample
hx-getAJAX GET requestLoad content dynamically
hx-postAJAX POST requestSubmit forms
hx-targetUpdate target elementSwap specific DOM
hx-swapSwap methodinnerHTML, outerHTML, beforeend
hx-triggerEvent triggerclick, change, load
hx-confirmConfirm dialogUser confirmation

Server-Side Handling

Alpine.js

Lightweight Reactivity

Alpine.js adds JavaScript interactivity declaratively:

Use Cases:

  • Dropdown menus
  • Modal dialogs
  • Form validation feedback
  • Toggle switches
  • Tabs

Integration with HTMX

Tailwind CSS

Utility-First Styling

Compose designs from utility classes:

Configuration

Tailwind is configured at the repository root (tailwind.config.js) and per-applet (e.g. modules/bichat/presentation/web/tailwind.config.js). There is no web/src/css/ path.

  • Custom colors for branding
  • Extended spacing scale
  • Plugin configurations

Component Architecture

Server Components

Pure server-rendered components:

Interactive Components

Components with Alpine.js interactivity:

State Management

Server State

Primary state lives on the server:

Client State

Minimal state in Alpine.js:

  • UI state (open/closed, selected tab)
  • Form draft state
  • Temporary user preferences

Best Practices

Progressive Enhancement

  1. Start with HTML - Works without JavaScript
  2. Add HTMX - Enhance with AJAX
  3. Add Alpine.js - Add interactivity where needed

Performance

  1. Minimize JS - Server-render when possible
  2. Partial Updates - HTMX for targeted updates
  3. Lazy Loading - Load components on demand
  4. Bundle Size - Alpine.js is ~15kb, minimal overhead

Comparison with SPA Frameworks

AspectIOTA SDKReact/Vue SPA
Initial LoadFast (HTML)Slower (JS bundle)
InteractivityProgressiveFull client-side
SEONativeRequires SSR
ComplexityLowerHigher
StateServer-firstClient-first

Next Steps

Last updated on