Beta documentation. This is an early preview — content is still in active development. Feedback helps shape the final release. Share your thoughts or join the discussion.

Quickstart

You need a Wapka site with the **Lua engine enabled**. Create one or switch an existing site:

On this page

Before you start

You need a Wapka site with the Lua engine enabled. Create one or switch an existing site:

  1. Go to your site overview → Site Settings
  2. Under Engine, select Lua Engine
  3. Scroll down to lua_init — this is where your script lives

Hello Wapka

Paste this into lua_init and click Save:

local app = framework()

app:get("/", function(ctx)
    return { message = "Hello, Wapka!" }
end)

Open your site in a browser. You'll see:

{ "message": "Hello, Wapka!" }

You just built a JSON API in 4 lines. No server setup, no deployment pipeline, no configuration.

Adding a second route

local app = framework()

app:get("/", function(ctx)
    return { message = "Home page" }
end)

app:get("/about", function(ctx)
    return {
        title = "About Us",
        team = { "Alice", "Bob", "Charlie" },
        founded = 2024
    }
end)

Visit /about — you'll see the team data as JSON.

Understanding what happened

  1. framework() created your app
  2. app:get("/", handler) said "when someone visits /, run this function"
  3. Your handler returned a Lua table — Wapka automatically converted it to JSON
  4. The response was sent with Content-Type: application/json

No routing config file. No web server setup. Just Lua.

What can a handler return?

You return Wapka sends
A table { key = "value" } JSON with correct headers
A string "Hello" Plain text or HTML
A number 404 That HTTP status code
ctx:render("page", data) Rendered HTML template
ctx:redirect("/url") HTTP redirect

Debugging

Stuck? Use print() and dump():

app:get("/debug", function(ctx)
    print("Someone visited /debug")
    dump(req.headers)       -- see all request headers
    dump(env)               -- see environment info
    return { ok = true }
end)

In debug mode (APP_DEBUG=true), the output appears in the response. In production, it's silently discarded.

Where to go from here

You want to Read
Understand all globals Globals Reference
Handle URL patterns Routing
Render HTML pages Twig Overview
Store and query data API Library

Tip: You can edit lua_init anytime. Changes go live immediately — no restart needed.

Previous Introduction to Lua Next Globals Reference