Documentation

Hello World

Browse documentation

Read this page as HTML, Markdown, or structured JSON—or open the published Markdown with an AI assistant. Gemini receives the prompt through your clipboard because its signed-out page does not reliably prefill URL text; paste when the new tab opens. External assistants need the public site URL.

Hello World

This recipe will help you to setup a Hello World! response in your /hello path.

First you need an amber project generated with Amber CLI or from scratch.

First create a src/controllers/hello_controller.cr file and add this:

src/controllers/hello_controller.cr
Crystal
class HelloController < ApplicationController
  def hello
    "Hello Amber!"
  end
end

Then add a new route in your config/routes.cr file:

Crystal
Amber::Server.configure do |app|
  pipeline :web do
    # pipelines...
  end

  routes :web do
    # other routes,,,
    get "/hello", HelloController, :hello
  end
end