Skip to main content

Installation

Install workerd-ftp using your preferred package manager.

Package managers

npm install workerd-ftp

Import the client

After installation, import the FTPClient class in your Worker:
import { FTPClient } from "workerd-ftp";

Prerequisites

Before using workerd-ftp, ensure you have the following:

Cloudflare Workers setup

1

Create a Workers project

If you don’t have a Workers project yet, create one using Wrangler:
npm create cloudflare@latest my-ftp-worker
Select “Hello World” Worker template when prompted.
2

Enable TCP Sockets

TCP Sockets require a Workers Paid plan. Free plans do not support this feature.
TCP Sockets must be enabled in your Cloudflare account. This is available on the Workers Paid plan and above.
3

Configure wrangler.toml

Ensure your wrangler.toml has the correct compatibility settings:
name = "my-ftp-worker"
main = "src/index.ts"
compatibility_date = "2024-01-01"

[env.production]
workers_dev = false

FTP server access

You’ll need:
  • Hostname: The FTP server address (e.g., ftp.example.com)
  • Port: Usually port 21 for FTP or 990 for FTPS
  • Credentials: Username and password for authentication
  • Security settings: Whether to use TLS encryption (secure: true for FTPS)
workerd-ftp only supports passive mode connections, as Cloudflare Workers can only make outgoing connections.

TypeScript support

workerd-ftp is written in TypeScript and includes full type definitions. No additional @types package is needed. The package exports:
  • FTPClient - Main client class
  • Type definitions for connection options and file information
import { FTPClient } from "workerd-ftp";

// TypeScript will automatically provide autocomplete and type checking
const ftp = new FTPClient('ftp.example.com', {
  port: 21,        // number
  user: 'john',    // string
  pass: 'secret',  // string
  secure: false    // boolean
});

Package information

Verify installation

To verify workerd-ftp is installed correctly, check your package.json:
{
  "dependencies": {
    "workerd-ftp": "^0.1.3"
  }
}

Next steps

Quick start

Learn how to connect to an FTP server and perform basic operations

Build docs developers (and LLMs) love