Fork me on GitHub

Familiar API

Luvit implements the same APIs as Node.js, but in Lua!

This helps teams migrate without having to learn a new way of programming.

Async Choice

Choose your async model; we don’t mind; we encourage experimentation.

If you don’t like callbacks and event emitters, use coroutines and write blocking style code without actually blocking your event loop!

Modular Core

The various projects in the luvit ecosystem can be mixed and matched to build the ideal runtime for your application.

  • Use luv directly in luajit
  • Use lit without node apis
  • The possibilities are endless

Using the Node-Style APIs

The luvit CLI tool can be used as a scripting platform just like node. This can be used to run lua scripts as standalone servers, clients, or other tools.

This simple web server written in Luvit responds with Hello World for every request.

local http = require('http')

http.createServer(function (req, res)
  local body = "Hello world\n"
  res:setHeader("Content-Type", "text/plain")
  res:setHeader("Content-Length", #body)
end):listen(1337, '')

print('Server running at')

And run this script using luvit.

> luvit server.lua
Server running at

This script is a standalone HTTP server, there is no need for Apache or Nginx to act as host.

Using Third-Party Libraries

Luvit also has a package system that makes it easy to publish and consume libraries.

For example, @creationix has made a set of libraries that use coroutines instead of callbacks for async I/O and published these to lit.

Using lit install creationix/weblit to use an express-like framework built on top of coroutines.

> mkdir myapp && cd myapp
> lit install creationix/weblit
> vim server.lua
> luvit server.lua

The server.lua file will contain:

local weblit = require('weblit')
  .bind({host = "", port = 1337})

  -- Configure weblit server

  -- A custom route that sends back method and part of url.
  .route({ path = "/:name"}, function (req, res)
    res.body = req.method .. " - " .. .. "\n"
    res.code = 200
    res.headers["Content-Type"] = "text/plain"

  -- Start the server

This very site is being served by weblit and its source can be found at

Permissive License

Luvit is licensed under the Apache 2.0 License to The Luvit Authors. This was done to make the project as accessible as possible to users and contributors.

Dive In

Join us on freenode IRC at #luvit, the Luvit Mailing list, or the Discord Server

We’ll be publishing tutorials here at the luvit blog soon, stay tuned.