Quickstart
Get up and running with Deno in just a few minutes by building your first web server.Make sure you have installed Deno before starting this tutorial.
Your first Deno program
Deno is most commonly used to build web servers. Let’s create a simple HTTP server that responds with “Hello, world!”.Create a server file
Create a new file called This code creates an HTTP server using Deno’s built-in
server.ts with the following TypeScript code:server.ts
Deno.serve() function. The server responds to every request with “Hello, world!”.Run the server
Run your server with the following command:The
--allow-net flag grants permission to access the network. Deno is secure by default, so you must explicitly grant permissions.Test your server
Open your browser and navigate to http://localhost:8000. You should see “Hello, world!” displayed.You can also test it from the command line:
Understanding the code
Deno.serve()
TheDeno.serve() function is Deno’s built-in HTTP server. It takes a handler function that receives a Request object and returns a Response:
Permissions
Deno is secure by default. The--allow-net flag grants permission to access the network. Without this flag, the program would fail with a permission error.
Learn more about Deno’s permission system.
Enhance your server
Add dynamic responses
server.ts
Return JSON
server.ts
Handle different HTTP methods
server.ts
Running with TypeScript
Deno has native TypeScript support. You can use TypeScript features without any configuration:server.ts
Development workflow
Watch mode
Use watch mode to automatically restart your server when files change:Type checking
Deno type-checks your code by default. To explicitly check types without running:REPL
Experiment with code interactively:Next steps
Now that you’ve built your first Deno application, explore more features:Core commands
Learn essential Deno commands
Permissions
Understand Deno’s security model
Testing
Write tests for your application
Configuration
Configure your Deno project
Troubleshooting
Permission denied errors
Permission denied errors
If you see permission errors, make sure you’re using the appropriate
--allow-* flags:Port already in use
Port already in use
If port 8000 is already in use, specify a different port:
TypeScript errors
TypeScript errors
Deno type-checks your code by default. If you encounter type errors, you can:
- Fix the type errors (recommended)
- Use
// @ts-ignoreto suppress specific errors - Use
--no-checkflag to skip type checking (not recommended)