https://github.com/arkforgelabs/astra
🔥 Blazingly Fast 🔥 web server runtime for Lua
https://github.com/arkforgelabs/astra
axum easytouse fast lua luajit nobuild rust server webserver
Last synced: 4 months ago
JSON representation
🔥 Blazingly Fast 🔥 web server runtime for Lua
- Host: GitHub
- URL: https://github.com/arkforgelabs/astra
- Owner: ArkForgeLabs
- License: apache-2.0
- Created: 2024-12-21T08:17:31.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-06-13T17:55:16.000Z (4 months ago)
- Last Synced: 2025-06-13T22:09:30.958Z (4 months ago)
- Topics: axum, easytouse, fast, lua, luajit, nobuild, rust, server, webserver
- Language: Rust
- Homepage: http://astra.arkforge.net/
- Size: 2.08 MB
- Stars: 56
- Watchers: 0
- Forks: 4
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://github.com/ArkForgeLabs/Astra/actions/workflows/linux_release.yml)
[](https://github.com/ArkForgeLabs/Astra/actions/workflows/windows_release.yml)
[](https://github.com/ArkForgeLabs/Astra/actions/workflows/crates_io_publish.yml)
[](https://discord.com/invite/6PMjUx8x3b)
[](https://astra.arkforge.net/docs/latest)Astra is a web server runtime for Lua (5.1-5.4), Luau and LuaJIT written in Rust. 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](https://arkforge.net) and many others.
## Installation
You can either get the binaries at [github releases](https://github.com/ArkForgeLabs/Astra/releases) or using `cargo` if you have it installed:
```bash
cargo install lua-astra
```To install with differet Lua VM, e.g. Lua 5.4:
```bash
cargo install lua-astra --no-default-features --features lua54
```## Example
```lua
-- Create a new server
local server = Astra.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
```lua
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
```lua
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.
```lua
-- spawn an async task that does not block the running thread
spawn_task(function ()
-- HTTP Request to check your IP address
local response = Astra.http.request("https://myip.wtf/json"):execute()
pprint(response:status_code())
pprint(response:remote_address())
pprint(response:body():json())
end)
```## Community Projects
- 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](https://github.com/ArkForgeLabs/Astra/issues/new)
## Note
This project may have breaking changes in minor versions until v1.0. Afterwhich semver will be followed. Contributions are always welcome!