Quickstart
Get up and running with Azu in 5 minutes! This guide will help you create your first Azu application and understand the core concepts.
Prerequisites
Crystal 0.35.0 or later
Basic familiarity with Crystal syntax
Step 1: Create a New Project
Create a new directory for your project:
mkdir my-azu-app
cd my-azu-appInitialize a new Crystal project:
crystal init app my_azu_appStep 2: Add Azu Dependency
Add Azu to your shard.yml:
dependencies:
azu:
github: your-org/azu
version: ~> 0.4.14Install dependencies:
Step 3: Create Your First Endpoint
Create src/endpoints/hello_endpoint.cr:
Step 4: Create Your Application
Create src/my_azu_app.cr:
Step 5: Run Your Application
Start your server:
You should see output like:
Step 6: Test Your Endpoints
Open your browser or use curl to test:
You should see JSON responses like:
What You've Built
Congratulations! You've created a fully functional Azu application with:
Type-safe endpoints that validate input and structure output
Request contracts that ensure data integrity
Response objects that format your data consistently
Routing that maps URLs to your endpoints
Configuration that's easy to modify
Key Concepts You've Learned
Endpoints
Endpoints are the core of Azu applications. They define:
What HTTP methods they handle (
get,post, etc.)What data they accept (Request contracts)
What data they return (Response objects)
The business logic that connects them
Request Contracts
Request contracts validate and type incoming data:
Automatic validation using the Schema library
Type safety for all parameters
Clear error messages when validation fails
Response Objects
Response objects structure your output:
Consistent data formatting
Type-safe serialization
Easy to test and maintain
Next Steps
Now that you have a working Azu application, explore these topics:
Tutorial - Build a more complete application
Endpoints - Deep dive into endpoint patterns
Request Contracts - Advanced validation techniques
Response Objects - Structured response handling
Real-time Features - Add WebSocket support
Templates - Build HTML responses
Common Patterns
Adding More Endpoints
Handling Different HTTP Methods
Error Handling
Troubleshooting
Common Issues
Port already in use:
Dependency issues:
Compilation errors:
Check that all required modules are included
Verify that request/response types match your endpoint definition
Ensure all dependencies are properly installed
What's Next?
Ready to build something more substantial? Check out the Tutorial to build a complete application with database integration, authentication, and real-time features!
You're now ready to start building amazing applications with Azu! 🚀
Last updated
Was this helpful?
