This article assumes that you have Crystal and Heroku CLI installed.
Create a sample application
Create a new application using$ crystal init app sample-appYou should see the following on your terminal
$ crystal init app sample-app
create sample-app/.gitignore
create sample-app/.editorconfig
create sample-app/LICENSE
create sample-app/README.md
create sample-app/.travis.yml
create sample-app/shard.yml
create sample-app/src/sample-app.cr
create sample-app/src/sample-app/version.cr
create sample-app/spec/spec_helper.cr
create sample-app/spec/sample-app_spec.cr
Initialized empty Git repository in /Users/yourname/Desktop/sample-app/.git/
now cd to the root of the app, $ cd sample-app and add Kemal to shrad.yml file
name: sample-app version: 0.1.0 authors: - John Doe <[email protected]> dependencies: kemal: github: kemalcr/kemal branch: master targets: sample-app: main: src/sample-app.cr crystal: 0.23.1 license: MITand run
$ crystal deps for installing dependencies.
Add a “/” route
Opensample-app.cr file and add replace the contents with the following code
require "kemal" get "/" do "Hello World" end Kemal.runnow run
$ crystal src/kemal_sample.cr and go to http://localhost:3000on your browser. You should see ur app running and the message ‘Hello World’.
Deploy to Heroku
So far so good 🙂 Now let us deploy our app to Heroku. Run $ heroku create your-custom-name –buildpack https://github.com/crystal-lang/heroku-buildpack-crystal.git You should see something like the following on your terminal.$ heroku create your-custom-name --buildpack https://github.com/crystal-lang/heroku-buildpack-crystal.git Creating ⬢ your-custom-name... done Setting buildpack to https://github.com/crystal-lang/heroku-buildpack-crystal.git... done https://your-custom-name.herokuapp.com/ | https://git.heroku.com/your-custom-name.gitYou are all set. Commit and push to heroku
$ git status $ git add -A $ git commit -m "commit message" $ git push heroku masterTo see your app running go to
https://your-custom-name.herokuapp.com/ . Congratulations you just deployed your crystal app to production
Happy Coding]]>

shrad.yml –> shard.yml