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 serve

Create 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 cli

Specify Database

Command Options

Option
Description
Default

--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)

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)

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)

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)

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)

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)

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:

  1. Setup database:

  2. Start development server:

Development

  • azu serve - Start development server

  • azu generate scaffold Post title:string - Generate resources

  • crystal spec - Run tests

Examples

Complete Blog Application

API Service

CLI Tool

Post-Creation Steps

After creating a new project:

  1. Navigate to project directory:

  2. Install dependencies:

  3. Setup database (if applicable):

  4. Start development:

  5. 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:

Last updated