Skip to main content
The templates command manages project templates, allowing you to create new projects from pre-configured templates or install community templates.

Usage

fern templates <command> [options]

Commands

list

List all available templates:
fern templates list
Available Templates
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Installed templates:
  📦 game
  📦 dashboard

Official templates:
  📦 basic      - Basic Fern application
  📦 game       - Game development template
  📦 dashboard  - Dashboard/admin template
  📦 mobile     - Mobile-style UI template

install

Install a template from a name or URL:
fern templates install <template_name_or_url>
template_name_or_url
string
required
Official template name or Git repository URL
Examples:
# Install official template
fern templates install game

# Install from GitHub URL
fern templates install https://github.com/user/fern-template

create

Create a new project from a template:
fern templates create <template_name> <project_name>
template_name
string
required
Name of installed template
project_name
string
required
Name for the new project
Example:
fern templates create game my_game
cd my_game
fern fire

Official Templates

basic

Simple Fern application template with minimal setup:
fern templates install basic
fern templates create basic my_app
Features:
  • Clean starter code
  • Basic rendering setup
  • Minimal dependencies
  • Good for learning

game

Game development template with player movement and input:
fern templates install game
fern templates create game my_game
Creating 'my_game' from template 'game'
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Project 'my_game' created from template 'game'!
cd my_game
fern fire
Features:
  • Player entity with keyboard controls
  • Game loop with update/draw separation
  • Input handling example
  • Sprite rendering
Starter code:
#include <fern/fern.hpp>
#include <iostream>
#include <cmath>

using namespace Fern;

// Game state
struct Player {
    float x = 400;
    float y = 300;
    float speed = 200;
};

Player player;

void update(float deltaTime) {
    // Simple player movement
    if (Input::isKeyPressed(KeyCode::Left)) {
        player.x -= player.speed * deltaTime;
    }
    if (Input::isKeyPressed(KeyCode::Right)) {
        player.x += player.speed * deltaTime;
    }
    if (Input::isKeyPressed(KeyCode::Up)) {
        player.y -= player.speed * deltaTime;
    }
    if (Input::isKeyPressed(KeyCode::Down)) {
        player.y += player.speed * deltaTime;
    }
}

void draw() {
    Draw::fill(Colors::DarkBlue);
    Draw::circle(player.x, player.y, 20, Colors::Yellow);
    DrawText::drawText("Use arrow keys to move", 10, 10, 1, Colors::White);
}

int main() {
    std::cout << "🎮 Starting Fern Game..." << std::endl;
    
    Fern::initialize();
    Fern::setUpdateCallback(update);
    Fern::setDrawCallback(draw);
    Fern::startRenderLoop();
    
    return 0;
}

dashboard

Dashboard and admin UI template:
fern templates install dashboard
fern templates create dashboard admin_panel
Features:
  • Panel layout system
  • Chart/graph examples
  • Navigation components
  • Data visualization ready

mobile

Mobile-style interface template:
fern templates install mobile
fern templates create mobile my_app
Features:
  • Touch-friendly UI
  • Responsive layout
  • Mobile navigation patterns
  • Gesture support

Installing Custom Templates

From Git URL

fern templates install https://github.com/username/fern-template-custom
This clones the repository to ~/.fern/templates/fern-template-custom.

Template Structure

Custom templates should have this structure:
my-template/
├── lib/
│   └── main.cpp
├── assets/
├── template.yaml    # Optional metadata
└── README.md

Template Metadata

Optional template.yaml:
name: My Custom Template
description: A custom Fern project template
author: Your Name
version: 1.0.0
tags:
  - game
  - multiplayer
features:
  - Networking support
  - Custom physics
  - Save/load system

Template Locations

Templates are stored in:
~/.fern/templates/
├── basic/
├── game/
├── dashboard/
└── custom-template/

Examples

Create Game from Template

# Install the game template
fern templates install game

# Create a new game project
fern templates create game space_shooter

# Navigate and run
cd space_shooter
fern fire

Use Custom Template

# Install custom template from GitHub
fern templates install https://github.com/ferncommunity/platformer-template

# Create project from it
fern templates create platformer-template my_platformer

# Run it
cd my_platformer
fern fire

List and Install

# See what's available
fern templates list

# Install what you need
fern templates install dashboard
fern templates install mobile

# List again to confirm
fern templates list

Workflow

1

Browse templates

fern templates list
2

Install template

fern templates install game
3

Create project

fern templates create game my_game
4

Start developing

cd my_game
fern fire

Creating Your Own Template

To create a template others can use:
1

Create template project

fern sprout my-template
cd my-template
2

Customize code

Edit lib/main.cpp and add your template code, assets, and structure.
3

Add metadata

Create template.yaml:
name: My Template
description: Description of what it does
author: Your Name
version: 1.0.0
4

Publish to Git

git init
git add .
git commit -m "Initial template"
git remote add origin https://github.com/you/fern-template-name
git push -u origin main
5

Share with others

Others can install it:
fern templates install https://github.com/you/fern-template-name

Common Issues

fern templates create game my_game
# Error: Template 'game' not found
Solution: Install the template first:
fern templates install game
fern templates create game my_game
fern templates create game my_game
# Error: Directory 'my_game' already exists
Solution: Choose a different name or remove the existing directory.
When installing from URL:
fern templates install https://github.com/invalid/repo
# Error: Failed to clone template
Solution: Verify the URL is correct and you have internet access.

Template vs Sprout

Featurefern sproutfern templates create
CodeBasic starterTemplate-specific
SetupMinimalPre-configured
Use CaseBlank slateSpecific project type
CustomizationFull freedomTemplate starting point
Use sprout for general projects, templates for specific project types.

Build docs developers (and LLMs) love