{ "code": 200, "data": { "description": "Once you have Dart installed, it only takes a few lines of code to set up your Relic server. These are the steps you need to take to get a simple Hello world server up and running.", "external": { "alternate": { "https://docs.dartrelic.dev/getting-started/hello-world-example": { "data-rh": "true", "hreflang": "x-default" } }, "canonical": { "https://docs.dartrelic.dev/getting-started/hello-world-example": { "data-rh": "true" } }, "icon": { "https://docs.dartrelic.dev/img/favicon.png": { "data-rh": "true" } }, "preconnect": { "https://www.google-analytics.com/": {}, "https://www.googletagmanager.com/": {} }, "prefetch": { "https://docs.dartrelic.dev/assets/js/0ca634c5.c40e5698.js": {}, "https://docs.dartrelic.dev/assets/js/17896441.35fb8100.js": {}, "https://docs.dartrelic.dev/assets/js/22dd74f7.32b10889.js": {}, "https://docs.dartrelic.dev/assets/js/2c10348c.c38ae9dc.js": {}, "https://docs.dartrelic.dev/assets/js/2dc195cc.c7b109bb.js": {}, "https://docs.dartrelic.dev/assets/js/441e1055.6248ef14.js": {}, "https://docs.dartrelic.dev/assets/js/4edc808e.d18ceb40.js": {}, "https://docs.dartrelic.dev/assets/js/5b00fbf1.0fa3fba9.js": {}, "https://docs.dartrelic.dev/assets/js/5e95c892.753674ac.js": {}, "https://docs.dartrelic.dev/assets/js/6783a3b2.0aa1428a.js": {}, "https://docs.dartrelic.dev/assets/js/9412f430.c708638d.js": {}, "https://docs.dartrelic.dev/assets/js/9576f52c.f029d9c3.js": {}, "https://docs.dartrelic.dev/assets/js/a7bd4aaa.b870ce93.js": {}, "https://docs.dartrelic.dev/assets/js/a94703ab.055f41b9.js": {}, "https://docs.dartrelic.dev/assets/js/a9685393.8fdc4764.js": {}, "https://docs.dartrelic.dev/assets/js/aba21aa0.1d722264.js": {}, "https://docs.dartrelic.dev/assets/js/aca04f59.28672d9f.js": {}, "https://docs.dartrelic.dev/assets/js/b4e2adc5.e5a3b2b2.js": {}, "https://docs.dartrelic.dev/assets/js/b685e31b.f5eb8692.js": {}, "https://docs.dartrelic.dev/assets/js/be2b5817.53d9f078.js": {}, "https://docs.dartrelic.dev/assets/js/c644a7fe.ad3a69e0.js": {}, "https://docs.dartrelic.dev/assets/js/c678908c.c170f033.js": {}, "https://docs.dartrelic.dev/assets/js/f22cf6c3.3fb896a1.js": {} } }, "html": "\n\n\nHello world | Relic\n\n\n\n\n\n\n\n\n\n\n
Skip to main content
Version: 1.0.0

Hello world

\n

Once you have Dart installed, it only takes a few lines of code to set up your Relic server. These are the steps you need to take to get a simple Hello world server up and running.

\n

Create a Dart package​

\n

First, you need to create a new Dart package for your Relic server.

\n
dart create -t console-full hello_world
\n

Add the Relic dependency​

\n

Next, add the relic package as a dependency to your pubspec.yaml file.

\n
cd hello_world
dart pub add relic
\n

Edit the main file​

\n

Edit the bin/hello_world.dart:

\n
Hello world server
import 'package:relic/relic.dart';

/// A simple 'Hello World' server demonstrating basic Relic usage.
Future<void> main() async {
// Setup the app.
final app = RelicApp()
// Route with parameters (:name & :age).
..get('/user/:name/age/:age', helloHandler)
// Middleware on all paths below '/'.
..use('/', logRequests())
// Custom fallback - optional (default is 404 Not Found).
..fallback = respondWith(
(_) => Response.notFound(
body: Body.fromString(\"Sorry, that doesn't compute.\\n\"),
),
);

// Start the server (defaults to using port 8080).
await app.serve();
}

/// Handles requests to the hello endpoint with path parameters.
Response helloHandler(final Request req) {
final name = req.rawPathParameters[#name];
final age = int.parse(req.rawPathParameters[#age]!);

return Response.ok(
body: Body.fromString('Hello, $name! To think you are $age years old.\\n'),
);
}
\n

What this code does:

\n
    \n
  1. Router and route: RelicApp() configures routing and registers a /user route.
  2. \n
  3. Middleware: use('/', logRequests()) logs each request for all paths under /.
  4. \n
  5. Server and fallback: app.serve() starts on port 8080; fallback handles unmatched routes and returns a 404 (not found).
  6. \n
\n

The result is a server that responds with a personalized greeting when you send a GET request matching /user/:name/age/:age.

\n

Running locally​

\n

Start your server with:

\n
dart bin/hello_world.dart
\n

Then, open your browser and visit http://localhost:8080/user/Nova/age/27, or use curl:

\n
curl http://localhost:8080/user/Nova/age/37
\n

You should see:

\n
Hello Nova! To think you are 27 years old.
\n

Congratulations! You just ran your first Relic server.

\n
tip

Relic works with hot reload out of the box. ⚡️ To use it, start your server in Debug mode from your IDE (or use dart run --enable-vm-service bin/hello_world.dart). Ensure that Hot Reload On Save is enabled in your IDE settings (typically, set it to manual which will trigger hot reload when you save your file).

\n\n", "metadata": { "description": "Once you have Dart installed, it only takes a few lines of code to set up your Relic server. These are the steps you need to take to get a simple Hello world server up and running.", "docsearch:docusaurus_tag": "docs-default-1.0.0", "docsearch:language": "en", "docsearch:version": "1.0.0", "docusaurus_locale": "en", "docusaurus_tag": "docs-default-1.0.0", "docusaurus_version": "1.0.0", "generator": "Docusaurus v3.9.2", "lang": "en", "og:description": "Once you have Dart installed, it only takes a few lines of code to set up your Relic server. These are the steps you need to take to get a simple Hello world server up and running.", "og:locale": "en", "og:title": "Hello world | Relic", "og:url": "https://docs.dartrelic.dev/getting-started/hello-world-example", "twitter:card": "summary_large_image", "viewport": "width=device-width, initial-scale=1.0" }, "publishedTime": "Wed, 18 Feb 2026 09:05:14 GMT", "title": "Hello world | Relic", "url": "https://docs.dartrelic.dev/getting-started/hello-world-example", "usage": { "tokens": 21616 } }, "meta": { "usage": { "tokens": 21616 } }, "status": 20000 }