Deno, created by Ryan Dahl (the same creator of Node.js), arrived as a secure and modern alternative to the traditional JavaScript runtime. Launched in 2020, Deno features native support for TypeScript, a restrictive permissions model, and a set of integrated tools (formatter, linter, test runner).
Why choose Deno?
- Security by default, the process does not have access to files, network or environment without the developer explicitly granting it.
- Native support for TypeScript, eliminates the need for external compilers.
- ES-M Modules, imports via URLs simplify dependency management.
- Integrated tools,
deno fmt,deno lintanddeno testcome ready-made, reducing dependence on external packages.
Quick installation
curl -fsSL https://deno.land/x/install/install.sh | sh ## ou via Homebrew brew install deno
The script adds the binary to
$PATH.
Structure of a Deno project
A typical Deno project maintains a lean organization. At the root are deno.json, which defines permissions, import-map and lint options, and README.md. The source code goes under the directory src/, with the entry point at main.ts and the helper modules in files like utils.ts. The tests are isolated in tests/, following the convention of names with a suffix _test.ts, such as main_test.ts.
Permissions, the heart of security
When running a script, you must specify which resources it can access:
| Permission | Description |
|---|---|
--allow-read | Reading files or directories. |
--allow-write | Writing to files or directories. |
--allow-net | Network connections (HTTP, TCP, UDP). |
--allow-env | Access to environment variables. |
--allow-run | Execution of subprocesses. |
--allow-ffi | Foreign Function Interface (C). |
Safe execution example
deno run --allow-net src/main.ts
The script can make HTTP requests, but not read local files.
ES-M modules via URL
Deno allows you to import directly from public URLs:
import { serve } from "https://deno.land/std@0.203.0/http/server.ts";
The module is cached in
~/.denoand can be versioned via tag.
Creating a simple HTTP server
import { serve } from "https://deno.land/std@0.203.0/http/server.ts"; const handler = (request: Request): Response => { const url = new URL(request.url); if (url.pathname === "/") { return new Response("Olá Deno!", { status: 200 }); } return new Response("Not Found", { status: 404 }); }; serve(handler, { port: 8000 });
The code above creates a server that responds
Olá Deno!at the root.
Integrated tests
Deno includes a lightweight test runner:
denon test --allow-net tests/main_test.ts
The test may use
assertEqualsfrom the standard library.
Test example (3 lines)
import { assertEquals } from "https://deno.land/std@0.203.0/testing/asserts.ts"; Deno.test("soma", () => assertEquals(2 + 2, 4));
Deploy in production
- Docker, official image
denoland/denosimplifies deployment.
FROM denoland/deno:alpine-1.38.0 WORKDIR /app COPY . . RUN deno cache src/main.ts EXPOSE 8000 CMD ["run", "--allow-net", "src/main.ts"]
- Edge, Deno Deploy (service serverless) accepts scripts directly via URL.
- CI/CD, GitHub Actions with
deno lint && deno test && deno fmt --checkguarantees quality.
Good security practices
- Minimum permissions, grant only what is necessary (
--allow-read=./data). - Lockfile, use
deno lockto lock module versions. - Dependency audit, check external URLs before trusting.
- Vulnerability scanning, tools like
trivycan analyze the Docker image.
Quick checklist to start a Deno project
- Install Deno (curl or brew).
- Create
deno.jsonwith minimum permissions. - Structure directories (
src,tests). - Write code using imports via URL.
- Add unit tests.
- Configure CI (lint, test, fmt).
- Containerize with Docker or use Deno Deploy.
- Review permissions before deployment.
Conclusion
Deno offers a secure, modern, and production-ready environment with fewer external dependencies. By adopting its restrictive permissions practices, ES-M modules, and integrated tools, developers can accelerate the delivery of robust applications and maintain a high standard of security.
What is your experience with Deno? Share in the comments!
Also read
- TypeScript for Applications: TypeScript Development Guide
- Cloudflare Workers: Practical Guide to Serverless Edge Computing
- Authorization and Permissions in Applications: Secure Access Control
- Authorization and Permissions - Best Practices Fundamentals
- Advanced TypeScript: Mastering Complex Types, Generics, and Utility Types
- Modern Web Development in 2025: Trends, Tools and Innovative Strategies
