Skip to main content
The deno init command scaffolds a new Deno project with a basic file structure.

Usage

deno init [OPTIONS] [DIR]

Description

Initialize a new Deno project with starter files including a main module, test file, and configuration file.

Flags

--lib
boolean
Initialize a library project with module exports and JSR publishing configuration
--serve
boolean
Initialize a server project with HTTP server example
--empty
boolean
Initialize an empty project with minimal setup
--package
string
Initialize from a template package (npm: or jsr: prefix)
--yes
boolean
Skip interactive prompts when using —package flag

Project Types

Default Project

Creates a basic project with:
  • main.ts - Main module with example function
  • main_test.ts - Test file
  • deno.json - Configuration file with tasks
deno init
deno init my-project

Library Project

Creates a library project ready for publishing to JSR:
  • mod.ts - Module entry point
  • mod_test.ts - Test file
  • deno.json - Configuration with name, version, and exports
deno init --lib
deno init --lib my-library

Server Project

Creates an HTTP server project:
  • main.ts - Server with routing examples
  • main_test.ts - Server tests
  • static/ - Static file directory
  • deno.json - Configuration with serve task
deno init --serve
deno init --serve my-server

Empty Project

Creates a minimal project:
  • main.ts - Simple hello world
  • deno.json - Basic configuration
deno init --empty

Initialize from Package

From npm

Initialize a project using an npm create package:
deno init --package npm:create-vite
deno init --package npm:create-next-app

From JSR

Initialize from a JSR template:
deno init --package jsr:@fresh/init

With arguments

Pass additional arguments to the initialization script:
deno init --package npm:create-vite -- my-app --template react

Examples

Initialize in current directory

deno init

Initialize in new directory

deno init my-project
cd my-project

Initialize a library

deno init --lib my-library
cd my-library
deno test

Initialize a server

deno init --serve my-server
cd my-server
deno task dev

Use a template without prompts

deno init --package npm:create-vite --yes

After Initialization

Once initialized, you can:
# Run the program
deno run main.ts

# Run with watch mode
deno task dev

# Run tests
deno test

# For library projects, publish to JSR
deno publish --dry-run

Build docs developers (and LLMs) love