Need help with Hexaville?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

123 Stars 5 Forks MIT License 268 Commits 12 Opened issues


The modern serverless web application engine and framework for Swift

Services available


Need anything else?

Contributors list

No Data


codebeat badge

Hexaville - The Serverless Framework using AWS Lambda + ApiGateway etc as a back end. Build applications comprised of microservices that run in response to events, auto-scale for you, and only charge you when they run. This lowers the total cost of maintaining your apps, enabling you to develop more, faster.

It's the greatest motivation to help many Swift and mobile application developers with rapid server side development and low cost operation.

Supported Cloud Servises

  • [x] AWS Lambda(Node.js 8.1 Runtime) + APIGateway
  • [ ] Google Cloud Function


  • Docker: using for builiding swift application
  • serverless: using for deployment

Deployment Engine


Recommended Database Clients

  • DynamoDB: A DynamoDB typesafe client in AWSSDKSwift

Example Application for Hexaville

HexavilleTODOExample has following practical examples for Hexaville application.

  • User authentication with GitHub's OAuth
  • Data persistence with DynamoDB
  • Dynamic HTML Rendering

Quick Start

Install Docker for mac

Install Docker for mac from here, If you haven't installed yet.

Install Hexaville from Script(Highly recommended)

curl -L | bash

The script clones the hexaville repository to

and adds the source line to your profile (~/.zshrc, or ~/.bashrc).
export PATH="$PATH:$HOME/.hexaville"

your profile and then, type
source ~/.bashrc

Install Hexaville from Source

git clone
cd Hexaville
swift build

and then, should link Hexaville executable path to /usr/local/bin or something like that.

Create a Project

Usage: hexaville generate 
hexaville generate Hello --dest /path/to/your/app


You can specify swift-tools-version for the new project with

option. Current default tool version is

If the tool version is higher than 3.1, layouts and definiations of

are refined.

e.g. ```sh

swift.version will be 5.1

hexaville generate Hello

swift.version will be 5.0

hexaville generate Hello --swift-tools-version 5.0

swift.version will be swift-4.0-DEVELOPMENT-SNAPSHOT-2017-08-04-a

hexaville generate Hello --swift-tools-version swift-4.0-DEVELOPMENT-SNAPSHOT-2017-08-04-a ```

Open your project with Xcode

swift package generate-xcodeproj
open *.xcodeproj

The created codes in the project is example snippet of

HexavilleFramework is an express like micro framework for Hexaville.

The syntax is following. ```swift import HexavilleFramework

let app = HexavilleFramework()


let router = Router()

router.use(.GET, "/") { request, context in let htmlString = "

HexavilleWelcome to Hexaville!" return Response(headers: ["Content-Type": "text/html"], body: htmlString) }


try ```

Deploy Your Project

Hexaville depends on serverless at deployment.

See Install Guide:

Packaging hexaville application

hexaville package
command does the following.
  • build a swift application on the docker(Ubuntu14.04) to create the ELF that is executed on servrless environment.
  • zip ELF, swift standard libraries, runtime program and assets
cd /path/to/your/app
hexaville package

Deploying to the cloud

serverless deploy --stage staging

Default serverless.yml that is created by

hexaville generate
has only staging and production environment. If you'd like to add other environments, please edit severless.yml manually.


1. What is executableTarget in Hexavillefile.yml?

is a name that specified in
products(name: 'executableTarget')
on Package.swift. In following case, it's a
let package = Package(
    name: "MyApp",
    products: [
        .executable(name: "my-app", targets: ["MyApp"])

Access to your api resources


or access the endpoint from Browser.

Binary Media Types

Currenty Hexaville supports following binary media types

  • image/*
  • application/octet-stream
  • application/x-protobuf
  • application/x-google-protobuf

How to get binary content?

Threr are two rules to respond to the binary content in the routing handler. * RowBinaryData should be encoded as Base64 * Adding

"Content-Type": "{BinaryMediaType}"
to the response headers
router.use(.get, "/some_image") { request, context in
    let imageData = Data(contentsOf: URL(string: "file:///path/to/your/image.jpeg")!)
    return Response(headers: ["Content-Type": "image/jpeg"], body: imageData.base64EncodedData())

Getting binary content from Hexaville, need to send request that includes

Content-Type: {BinaryMediaType}
Accept: {BinaryMediaType}
curl --request GET -H "Accept: image/jpeg" -H "Content-Type: image/jpeg"

????JFIF``??;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 70





How to debug?

You can debug your application with the HexavilleFramework's builtin web server with serve command.

/path/to/your/app/.build/debug/Hello serve
# => Hexaville Builtin Server started at

Advanced Settings

Environment Variables


VPC and Security Groups


Swift Versioning and Build Configuration

You can configure swift versioning and build configuration in

  • default swift version is
  • default build configuration is
  version: 5.1 #format should be major.minor.[patch] or valid SWIFT DEVELOPMENT-SNAPSHOT name
    configuration: release


You can also specify SWIFT DEVELOPMENT-SNAPSHOT as internal using swift version.
The format is same as swiftenv version


  version: swift-4.0-DEVELOPMENT-SNAPSHOT-2017-08-04-a

Static Assets

You can also upload static assets. Just put your assets into the

directory in your project root.

Loading Static Assets in Application

You can load static assets from local filesystem with

import HexavilleFramework

let data = try AssetLoader.shared.load(fileInAssets: "/html/index.html")

Against for the Severless weak points

Too many connections will created between Serveless functions and RDB, Cache Server

Almost Web develoeprs access RDB, Cache Server through connection pooling from your applications. It's a one of the best practice for reducing connection for them. But Functions that are called on Serverless is like a Pre-Folk. It means can not have connection pooling and the number of connection of Database is same as number of functions that are executed in parallel.

In that case, Hexaville provides you to connection pooling mechanism with hexaville-tcp-proxy-server.

hexaville-tcp-proxy-server is not only a Proxy Sever But Connection Pooling Server. See the detail to see README.

Cold Start

There are several third parties's libraries to againt cold start on github.

The major one is serverless-plugin-warmup

How to update Hexaville CLI Version?

$ rm -rf ~/.hexaville
$ curl -L | bash
$ hexaville version


All developers should feel welcome and encouraged to contribute to Hexaville, see our getting started document here to get involved.

To contribute a feature or idea to Hexaville, submit an issue and fill in the template. If the request is approved, you or one of the members of the community can start working on it.

If you find a bug, please submit a pull request with a failing test case displaying the bug or create an issue.

If you find a security vulnerability, please contact [email protected] as soon as possible. We take these matters seriously.

Related Articles


Hexaville is released under the MIT license. See LICENSE for details.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.