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.

Introduction to Lua

Lua is a lightweight, fast scripting language. It powers games (Roblox, World of Warcraft), embedded systems, and now your Wapka site.

On this page

Lua on Wapka

Lua is a lightweight, fast scripting language. It powers games (Roblox, World of Warcraft), embedded systems, and now your Wapka site.

New to Lua? Read Learn Lua in Y Minutes or the official Lua 5.4 manual. You only need the basics — Wapka handles the heavy lifting.

How Wapka runs your code

Wapka executes Lua inside PHP LuaSandbox — a secure sandbox with CPU and memory limits. Your code cannot touch the filesystem, call PHP functions, or access other sites' data. It's safe by default.

When a visitor hits your site:

Browser Request
  → Wapka loads your site
    → Runs lua_init (your script)
      → framework() creates your app
        → Route matching finds the right handler
          → Your handler runs, returns data
            → Wapka sends the response

What you can build

Idea With
REST API backend Routes + api.dataset
Blog with comments Routes + Twig templates + api.posts
User dashboard api.users + ctx:render
E-commerce store api.dataset for products + http.* for payments
Contact form Validator + api.messages
Real-time data api.dataset.find + JSON responses

Your first script

local app = framework()

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

Save this in your site's lua_init setting. Visit your site. You'll see {"message":"Hello, Wapka!"}. That's a real JSON API — zero configuration, instant deployment.

The big picture

Every script gets these tools for free:

Tool What it does
framework() Create your app
app:get(), app:post() Define routes
ctx:render() Render HTML templates
api.* Work with users, posts, files, data
http.* Call external APIs
validator() Check user input
url.*, hash.*, str.* Utility libraries
req, env Read request and environment info
print(), dump() Debug your code

Next: Quickstart — get your first site running in 2 minutes.

Next Quickstart