azu new
The azu new command creates a new Azu project from scratch. This is the primary way to start a new application with Azu CLI.
Overview
azu new <project_name> [options]Basic Usage
Create a Simple Web Application
# Create a new web application
azu new my_blog
# Navigate to the project
cd my_blog
# Start development
azu serveCreate Different Project Types
# Web application (default)
azu new my_web_app --type web
# API-only application
azu new my_api --type api
# or use the shorthand:
azu new my_api --api
# CLI application
azu new my_cli_tool --type cliSpecify Database
Command Options
--type <type>
Project type (web, api, cli)
web
--database <db>
Database type (postgres, mysql, sqlite)
postgres
--template <name>
Use specific template
default
--skip-git
Skip Git repository initialization
false
--skip-deps
Skip dependency installation
false
--force
Overwrite existing directory
false
Project Types
Web Application (--type web)
--type web)Full-stack web applications with HTML templates, CSS, and JavaScript.
Features:
HTML page rendering with Jinja2 templates
Static asset management (CSS, JS, images)
Real-time components with WebSocket support
Complete MVC architecture
Generated Structure:
API Application (--type api)
--type api)API-only applications for building REST APIs, microservices, or mobile backends.
Features:
JSON API endpoints
Request/response contracts
No HTML templates or static assets
Optimized for API development
Generated Structure:
CLI Application (--type cli)
--type cli)Command-line applications and tools.
Features:
Command-line interface
No web server or database (unless added)
Focused on CLI development
Generated Structure:
Database Options
PostgreSQL (--database postgres)
--database postgres)Recommended for production applications.
Features:
Full ACID compliance
Advanced features (JSON, arrays, etc.)
Excellent performance
Rich ecosystem
Requirements:
PostgreSQL server installed
Database user with create privileges
MySQL (--database mysql)
--database mysql)Good for web applications and smaller projects.
Features:
Widely supported
Good performance
Easy to find hosting
Requirements:
MySQL server installed
Database user with create privileges
SQLite (--database sqlite)
--database sqlite)Perfect for development, prototypes, and simple applications.
Features:
No server required
File-based database
Zero configuration
Great for development
Use Cases:
Development and testing
Simple applications
Prototypes and demos
Embedded applications
Advanced Options
Custom Templates
Use a custom project template:
Skip Git Initialization
Skip Dependencies
Force Overwrite
Generated Files
Core Application Files
src/<project_name>.cr - Main application module:
src/server.cr - HTTP server configuration:
Configuration Files
shard.yml - Crystal dependencies:
README.md - Project documentation:
Setup database:
Start development server:
Development
azu serve- Start development serverazu generate scaffold Post title:string- Generate resourcescrystal spec- Run tests
Examples
Complete Blog Application
API Service
CLI Tool
Post-Creation Steps
After creating a new project:
Navigate to project directory:
Install dependencies:
Setup database (if applicable):
Start development:
Generate your first resource:
Troubleshooting
Permission Denied
Database Connection Error
Template Not Found
Best Practices
1. Choose the Right Project Type
Web: Full-stack applications with UI
API: Backend services and microservices
CLI: Command-line tools and utilities
2. Select Appropriate Database
PostgreSQL: Production applications, complex data
MySQL: Web applications, shared hosting
SQLite: Development, prototypes, simple apps
3. Use Descriptive Names
4. Plan Your Structure
Before creating the project, consider:
Project type (web, API, CLI)
Database requirements
Deployment environment
Team size and workflow
The azu new command is your starting point for all Azu applications. Choose the right options for your project type and requirements to get the best foundation for your development.
Next Steps:
Project Structure - Understand the generated structure
Quick Start - Build your first feature
Database Commands - Manage your database
Last updated