-
Notifications
You must be signed in to change notification settings - Fork 0
Create your first Stir Fry!
Tim Anema edited this page Sep 7, 2026
·
1 revision
Getting started is easy! We can have an app running in a few minutes.
- Create your project directory
mkdir my_app && cd myapp - Create a
Gemfilefile and add the following contents:
# frozen_string_literal: true
source "https://rubygems.org"
gem "stir_fry"
gem "puma"- Run
bundle install - Add the following to
app.rb
# frozen_string_literal: true
require "stir_fry"
class Layout < StirFry::Component
end
class Home < StirFry::Component
end
class Greet < StirFry::Component
attr_reader :name
def initialize(name:, **)
super
logger.info("Greeting #{name}")
@name = name
end
end
class App < StirFry::App
get "/", Home
get "/:name", Greet
get "/api/:name" do |name:, response:, **|
response.json({message: "Hello #{name}!"})
end
end
__END__
@@Layout
<html>
<body>
{ yield }
</body>
</html>
@@Home
<Layout>
<h1>Hello World</h1>
</Layout>
@@Greet
<Layout>
<h1>Hello {name}!</h1>
</Layout>- Create a file
config.ruwith the following contents:
require_relative "app"
run App- Run
bundle exec stirfryand get frying!