Astra is a web server runtime for Lua (5.1-5.4), Luau and LuaJIT written in Rust with native support for Teal. The goal is to get as much performance as possible while writing the web server logic in Lua instead for faster iteration, fault-tolerance and no-build requirements. This project is internally used here at ArkForge and many others.
MSRV: 1.88+
You can either get the binaries at github releases or
cargo install lua-astraTo install with differet Lua VM, e.g. Lua 5.4:
cargo install lua-astra --no-default-features --features lua54curl -fsSL https://raw.githubusercontent.com/ArkForgeLabs/Astra/refs/heads/main/linux_install.sh | bashpowershell -c "irm https://raw.githubusercontent.com/ArkForgeLabs/Astra/refs/heads/main/windows_install.ps1 | iex"-- Create a new server
local server = require("http").server.new()
-- Register a route
server:get("/", function()
return "hello from default Astra instance!"
end)
-- Configure the server
server.port = 3000
-- Run the server
server:run()You can also use the local variables within routes
local counter = 0
server:get("/count", function()
counter = counter + 1
-- and also can return JSON
return { counter = counter }
end)Requests and Responses and their configuration are provided when needed
server:get("/", function(request, response)
-- set header code
response:set_status_code(300)
-- set headers
response:set_header("header-key", "header-value")
-- consume the request body
print(request:body():text())
return "Responding with Code 300 cuz why not"
end)There are also utilities provided such as a PostgreSQL/SQLite, http client requests, lua extra utils, and async tasks.
-- spawn an async task that does not block the running thread
spawn_task(function ()
-- HTTP Request to check your IP address
local response = require("http").request("https://myip.wtf/json"):execute()
pprint(response:status_code())
pprint(response:remote_address())
pprint(response:body():json())
end)- Astra Trails - https://github.com/0riginaln0/astra-trails
If you have a project that uses or extends Astra, let us know about it by extending the list above or opening a new issue
This project may have breaking changes in minor versions until v1.0. Afterwhich semver will be followed. Contributions are always welcome!
