Skip to content
spaceport / docs
The Spaceport handbook

Developer Onboarding

This guide takes you from zero to a running Spaceport application. By the end, you will have installed the prerequisites, created a project, written your first route handler, rendered a template, and understood the core concepts you will use every day as a Spaceport developer.

Prerequisites

Spaceport needs three things on your system:

Prerequisite Minimum Version Recommended
Java (JDK or JRE) Java 8 SE bytecode target Java 21 (verified Frontier runtime)
Apache CouchDB 2.0 3.5.x or later
Spaceport JAR Latest Latest

You will also need a terminal, a web browser, and a text editor. Any editor works — Spaceport has no build step, so there is no IDE dependency. For .ghtml support, use Spaceport Ground Control in IntelliJ or the Spaceport Sublime Text plugin.

Groovy Knowledge

Spaceport server code is written in Groovy, a JVM language that is fully compatible with Java. If you know Java, you already know most of Groovy. The key differences you will encounter immediately are:

You do not need to be a Groovy expert to start. Spaceport source modules are plain Groovy classes, and the framework handles compilation for you.

For a more thorough Groovy primer tailored to Spaceport patterns, see Groovy Luminary.

Editor and IDE Setup

Spaceport has no build step and no IDE requirement — any text editor works. However, a few tools make the experience significantly better:

JetBrains IntelliJ IDEA (recommended)

Use Spaceport Ground Control for dedicated .ghtml editing in IntelliJ-based IDEs. Version 1.1.0 targets IntelliJ Platform 2026.2 (build 262 or newer), with Groovy and YAML support enabled.

Install its ZIP through Settings → Plugins → the gear menu → Install Plugin from Disk, then restart the IDE. Ground Control supplies GHTML/HTML/Groovy completion, cross-island type inference, element navigation, manifest schema completion, source-root recognition, route inspections, and manifest-generated run configurations.

Ground Control builds require JDK 25; this is separate from the Java requirement for running a Spaceport application. See Scaffolds API for build commands.

IntelliJ IDEA with JetBrains Gateway (remote development)

If your Spaceport application runs on a remote server, JetBrains Gateway lets you develop remotely with a local IDE experience. Enable SSH on your server, install Gateway locally, and connect — all file operations happen on the remote machine with hot-reload working as normal.

Sublime Text

A lightweight alternative with Spaceport-specific support. Install the Spaceport plugin for .ghtml syntax highlighting.

IDE Tip: Language Injection

In IntelliJ, you can get syntax highlighting inside embedded strings by using language injection comments. Spaceport's real-world code uses this pattern for CouchDB view functions and Server Element JavaScript:

// JavaScript highlighting inside a Groovy string
@Javascript String constructed = /* language=javascript */ """
    function(element) {
        element.listen('click', function(e) {
            // IntelliJ highlights this as JavaScript
        })
    }
"""

// JavaScript highlighting for CouchDB map functions
ViewDocument.get('jobs', 'jobs').setViewIfNeeded(
    'list-jobs', /* language=javascript */ '''
        function(doc) {
            if (doc.type === 'job') emit(doc.created, doc);
        }
    '''
)

The /* language=javascript */ comment is stripped during processing — it exists purely for IDE support.

Installing Java

Check if Java is already installed:

java -version

If you see a version number (1.8 or higher), you are set. If not, install a JDK. For development, any distribution works. For production, an LTS distribution avoids frequent upgrades:

On Debian/Ubuntu, the quickest path is:

sudo apt install default-jre

For verified build and runtime baselines, see Compatibility Notes.

Installing CouchDB

CouchDB is the database that backs all persistent data in Spaceport. Install it from the CouchDB downloads page or through your system package manager.

During installation:

  1. Choose standalone mode (not clustered) for local development
  2. Set the bind address to 127.0.0.1 on Linux or localhost on Windows
  3. Set an admin password and note it down — you will need it when configuring Spaceport

After installation, verify CouchDB is running by visiting http://localhost:5984/_utils/ in your browser. You should see the Fauxton web interface. This admin panel is useful for inspecting your databases during development, but Spaceport handles all database operations for you through its Documents API.

Getting the Spaceport JAR

Spaceport is distributed as a single JAR file. Download the latest version from the Spaceport builds repository and place it in a directory of your choice. All Spaceport commands are run through this JAR:

java -jar spaceport.jar --help

If you want a shorter command, create a shell alias or wrapper script:

alias spaceport='java -jar /path/to/spaceport.jar'

For full CLI documentation, see CLI Overview.

Creating a Project

You can create a new Spaceport project with Create Spaceport App or a starter kit.

Option A: Create Spaceport App

Use Create Spaceport App for AI-assisted setup, clone a starter kit, or create a project manually. See Scaffolds Overview.

git clone https://github.com/spaceport-dev/create-spaceport-app my-project
cd my-project

Follow the repository's documentation-fetch instructions, then its BOOTSTRAP.md workflow. Download the framework JAR separately.

Option B: Download a Starter Kit

If you prefer starting from a pre-built project you can inspect and modify:

Clone the repository, update the manifest with your CouchDB credentials, and you are ready to go.

Option C: Zero-Config Start

For the fastest possible start with no setup at all:

mkdir my-app && cd my-app
mkdir modules

Create modules/App.groovy (we will write the contents in a moment), then start Spaceport without a manifest:

java -jar spaceport.jar --start --no-manifest

Spaceport binds to 127.0.0.1:10000, looks for source modules in modules/, and connects to CouchDB at the default address. This mode is great for learning, but use a manifest file for anything beyond quick experiments.

Project Directory Structure

A typical Spaceport project looks like this:

my-app/
  config.spaceport          # Manifest configuration (YAML)
  modules/                  # Groovy source modules (your server code)
    App.groovy
    Router.groovy
    documents/              # Subdirectories become Java packages
      Message.groovy
  launchpad/                # Launchpad template files
    parts/                  # Page templates (.ghtml files)
      index.ghtml
      about.ghtml
    elements/               # Reusable template components
  assets/                   # Static files (CSS, JS, images)
    css/
    js/
    images/
  stowaways/                # Third-party JAR libraries
  migrations/               # Database migration scripts

The key directories are:

The manifest tells Spaceport where to find everything. A minimal config.spaceport looks like:

host:
  port: 10000

memory cores:
  main:
    username: admin
    password: your-couchdb-password

source modules:
  paths:
    - modules/*

debug: true

You only need to specify what differs from the defaults. Everything else is filled in automatically. See Manifest Overview for the full default configuration and all available keys.

Your First Route: Hello World

Create modules/App.groovy with the following content:

import spaceport.computer.alerts.Alert
import spaceport.computer.alerts.results.HttpResult

class App {

    @Alert('on / hit')
    static _index(HttpResult r) {
        r.writeToClient('<h1>Hello from Spaceport!</h1>')
    }

}

Start the server:

java -jar spaceport.jar --start --no-manifest

Open http://localhost:10000 in your browser. You should see "Hello from Spaceport!" rendered as a heading.

Here is what happened:

  1. Spaceport scanned the modules/ directory and found App.groovy
  2. It compiled the class and discovered the @Alert('on / hit') annotation
  3. It registered the _index method as a handler for HTTP requests to /
  4. When your browser sent a GET request to /, Spaceport dispatched the event and called your method
  5. r.writeToClient() wrote the HTML string directly to the HTTP response

The @Alert annotation is the core of Spaceport's event system. The string 'on / hit' is an event string that matches HTTP requests to the root path. Every route, every lifecycle hook, and every event listener in Spaceport uses this same annotation. See Alerts Overview for the full story.

Adding a Second Route

Add another method to App.groovy:

import spaceport.computer.alerts.Alert
import spaceport.computer.alerts.results.HttpResult

class App {

    @Alert('on / hit')
    static _index(HttpResult r) {
        r.writeToClient('<h1>Hello from Spaceport!</h1><p><a href="/about">About</a></p>')
    }

    @Alert('on /about hit')
    static _about(HttpResult r) {
        r.writeToClient('<h1>About</h1><p>This is my first Spaceport app.</p>')
    }

}

If you started with debug: true (which is the default in no-manifest mode), save the file and Spaceport will hot-reload your modules automatically. No restart needed. Visit http://localhost:10000/about to see the new page.

Hot-reloading compiles and reloads all source modules within milliseconds of a file save. This tight feedback loop is one of Spaceport's core development advantages. See Source Modules Overview for details on how it works.

Rendering Templates with Launchpad

Writing HTML inside writeToClient() strings is fine for simple responses, but real pages need Launchpad templates. Launchpad is Spaceport's server-side templating engine. Templates are .ghtml files — HTML with embedded Groovy code — stored in launchpad/parts/.

Create the template directory and two files:

launchpad/parts/wrapper.ghtml — a layout wrapper that wraps every page:

<!DOCTYPE html>
<html>
<head>
    <title>My First App</title>
</head>
<body>
    <nav>
        <a href="/">Home</a> |
        <a href="/about">About</a>
    </nav>
    <main>
        <payload/>
    </main>
</body>
</html>

The <payload/> tag marks where assembled page content goes.

launchpad/parts/index.ghtml — the home page content:

<%
    def greeting = 'Hello from Launchpad!'
    def timestamp = new Date().format('h:mm a')
%>

<h1>${ greeting }</h1>
<p>Server time: ${ timestamp }</p>

Now update App.groovy to use Launchpad:

import spaceport.computer.alerts.Alert
import spaceport.computer.alerts.results.HttpResult
import spaceport.launchpad.Launchpad

class App {

    static Launchpad launchpad = new Launchpad()

    @Alert('on / hit')
    static _index(HttpResult r) {
        launchpad.assemble(['index.ghtml']).launch(r, 'wrapper.ghtml')
    }

}

The pattern is always the same: assemble() selects which template files to combine, and launch() renders them into the HTTP response. The second argument to launch() is the wrapper template.

Save all three files. With hot-reload active, visit http://localhost:10000 and you will see your templated page with the nav bar, greeting, and server time.

For the full templating system including reactive bindings, server actions, and template composition, see Launchpad Overview.

Key Concepts

Now that you have a running application, here is a quick map of the major systems you will work with as you build out your project.

Alerts — The Event System

Alerts are Spaceport's unified event system. Every HTTP request, WebSocket message, document save, and lifecycle event is dispatched as an Alert. Your code listens with the @Alert annotation.

@Alert('on /login POST')           // Handle POST to /login
@Alert('on initialized')           // Run code at startup
@Alert('on document saved')        // React when any document is saved
@Alert('on socket connect')        // Handle new WebSocket connections

Alerts support priorities for ordering (authentication checks before route handlers) and cancellation for short-circuiting (redirect unauthenticated users before the page renders). One annotation, one pattern, for everything.

Read more: Alerts Overview

Source Modules — Your Server Code

Source modules are the Groovy classes in your modules/ directory. Spaceport compiles them at startup — no build step required. In debug mode, saving a file triggers automatic hot-reload.

Subdirectories map to Java packages. All modules share one classloader, so any class can reference any other. Structure your code however makes sense for your project.

Read more: Source Modules Overview

Launchpad — Server-Side Templating

Launchpad renders .ghtml templates on the server with full access to your Groovy code, database, and session state. Beyond basic templating, it provides reactive bindings (${{ }}) that push live DOM updates when server data changes, and server actions (_{ }) that bind Groovy closures to client-side events like clicks and form submissions.

Read more: Launchpad Overview

Cargo — Reactive Data Containers

Cargo is a reactive key-value store. When you update a Cargo value, any Launchpad template bound to it re-renders automatically on the client via WebSocket. Cargo comes in three modes: in-memory, server-wide shared, and CouchDB-backed persistent. Every user session also has a per-session Cargo called the dock.

Read more: Cargo Overview

Documents — CouchDB ORM

Documents are Spaceport's data layer. The Document class maps Groovy objects to CouchDB JSON documents with automatic serialization, revision tracking, and lifecycle events. You can use the base Document class for simple key-value storage or extend it to create typed data models with custom properties and business logic.

Read more: Documents Overview

Manifest — Configuration

The config.spaceport file (YAML format) controls how your application starts: host, port, database connection, source module paths, static asset paths, debug mode, and any custom keys your application needs. Spaceport deep-merges your configuration over sensible defaults, so you only specify what you want to change.

Read more: Manifest Overview

The Development Loop

With your project running in debug mode, the development loop is:

  1. Edit a .groovy source module or .ghtml template
  2. Save the file
  3. Refresh your browser (or watch reactive bindings update automatically)

There is no compile step, no build command, no restart. Spaceport watches for file changes and hot-reloads within milliseconds. This feedback loop lets you iterate rapidly and experiment freely.

Quick Start Checklist

Next Steps

Once you are comfortable with the basics, pick a path:

Hands-on tutorials:

Deep dives into core systems:

Starter projects to explore:

Make the docs better.Edit this page on GitHub