Convert Figma logo to code with AI

cloudflare logowrangler-legacy

🤠 Home to Wrangler v1 (deprecated)

3,200
337
3,200
0

Top Related Projects

🤠 Home to Wrangler v1 (deprecated)

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®

🔥 Fully-local simulator for Cloudflare Workers. For the latest version, see https://github.com/cloudflare/workers-sdk/tree/main/packages/miniflare.

Write Cloudflare Workers in 100% Rust via WebAssembly

12,783

Develop. Preview. Ship.

1,576

Netlify Command Line Interface

Quick Overview

Wrangler-legacy is the command-line interface for Cloudflare Workers, designed to help developers build and manage serverless applications. It provides tools for creating, testing, and deploying Workers projects, as well as managing KV namespaces and other Cloudflare resources.

Pros

  • Easy-to-use CLI for managing Cloudflare Workers projects
  • Supports local development and testing of Workers
  • Integrates well with Cloudflare's ecosystem and services
  • Provides scaffolding and templates for quick project setup

Cons

  • This is a legacy version, and users are encouraged to migrate to the newer Wrangler 2
  • May lack some of the latest features and improvements found in newer versions
  • Could have compatibility issues with newer Cloudflare Workers features
  • Limited documentation and support compared to the current version

Code Examples

  1. Creating a new Workers project:
wrangler generate my-worker
cd my-worker
  1. Developing and testing a Worker locally:
wrangler dev
  1. Publishing a Worker to Cloudflare:
wrangler publish
  1. Managing KV namespaces:
wrangler kv:namespace create "MY_NAMESPACE"
wrangler kv:key put --binding=MY_NAMESPACE "key" "value"

Getting Started

To get started with wrangler-legacy, follow these steps:

  1. Install wrangler-legacy globally:

    npm install -g @cloudflare/wrangler@legacy
    
  2. Authenticate with your Cloudflare account:

    wrangler login
    
  3. Create a new Workers project:

    wrangler generate my-project
    cd my-project
    
  4. Edit your wrangler.toml file to configure your project settings.

  5. Develop and test your Worker locally:

    wrangler dev
    
  6. When ready, publish your Worker to Cloudflare:

    wrangler publish
    

Note: It's recommended to migrate to the newer Wrangler 2 for the latest features and improvements.

Competitor Comparisons

🤠 Home to Wrangler v1 (deprecated)

Pros of wrangler-legacy

  • Established codebase with a longer history of development and usage
  • May have better compatibility with older Cloudflare Workers projects
  • Potentially more stable and well-tested for legacy use cases

Cons of wrangler-legacy

  • Lacks newer features and improvements found in the current Wrangler version
  • May not receive as frequent updates or bug fixes as the main Wrangler project
  • Could become obsolete as Cloudflare continues to develop and improve their tooling

Code Comparison

wrangler-legacy:

pub fn main() {
    let mut app = App::new("wrangler");
    app = build_app(app);
    let matches = app.get_matches();
    run(matches);
}

wrangler-legacy:

pub fn main() {
    let mut app = App::new("wrangler");
    app = build_app(app);
    let matches = app.get_matches();
    run(matches);
}

As both repositories refer to the same project (wrangler-legacy), there are no significant differences in the code structure or implementation. The main distinction lies in the fact that wrangler-legacy is a deprecated version of the Wrangler CLI tool, while the current Wrangler project continues to receive updates and new features.

⛅️ Home to Wrangler, the CLI for Cloudflare Workers®

Pros of workers-sdk

  • More actively maintained and updated
  • Supports newer Cloudflare Workers features
  • Improved performance and stability

Cons of workers-sdk

  • Potential learning curve for users familiar with wrangler-legacy
  • May have compatibility issues with older projects

Code Comparison

wrangler-legacy:

wrangler init my-project
wrangler preview --watch
wrangler publish

workers-sdk:

npx wrangler init my-project
npx wrangler dev
npx wrangler deploy

Key Differences

  • workers-sdk uses npx for command execution
  • preview command is replaced with dev in workers-sdk
  • publish command is now deploy in workers-sdk

Migration Considerations

  • Review project configuration files for compatibility
  • Update CI/CD pipelines to use new commands
  • Test thoroughly before switching production deployments

Community and Support

  • workers-sdk has more active community support
  • More extensive documentation available for workers-sdk
  • wrangler-legacy may have limited support for newer features

Performance

  • workers-sdk generally offers improved build and deployment speeds
  • Better handling of large projects and dependencies

Conclusion

While wrangler-legacy is still functional, workers-sdk provides a more modern and feature-rich experience for Cloudflare Workers development. Users should consider migrating to workers-sdk for better long-term support and access to newer features.

🔥 Fully-local simulator for Cloudflare Workers. For the latest version, see https://github.com/cloudflare/workers-sdk/tree/main/packages/miniflare.

Pros of miniflare

  • Faster local development with hot reloading
  • More accurate simulation of Cloudflare Workers environment
  • Supports a wider range of Workers features and APIs

Cons of miniflare

  • Less integrated with Cloudflare's deployment workflow
  • May require additional setup compared to wrangler-legacy
  • Potentially steeper learning curve for new users

Code Comparison

wrangler-legacy:

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  return new Response('Hello World!')
}

miniflare:

export default {
  async fetch(request, env, ctx) {
    return new Response('Hello World!')
  }
}

The main difference is that miniflare uses the newer module syntax for Workers, while wrangler-legacy uses the older service worker syntax. miniflare's approach is more aligned with current Cloudflare Workers best practices.

Write Cloudflare Workers in 100% Rust via WebAssembly

Pros of workers-rs

  • Native Rust support for Cloudflare Workers, allowing for better performance and memory safety
  • Direct integration with Rust ecosystem and tooling
  • More granular control over Worker behavior and resource usage

Cons of workers-rs

  • Steeper learning curve for developers not familiar with Rust
  • Less mature ecosystem compared to JavaScript-based Workers
  • Limited compatibility with existing JavaScript Worker libraries

Code Comparison

wrangler-legacy (JavaScript):

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  return new Response('Hello World!')
}

workers-rs (Rust):

use worker::*;

#[event(fetch)]
pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result<Response> {
    Response::ok("Hello World!")
}

The workers-rs example demonstrates a more concise and type-safe approach to creating a Cloudflare Worker, leveraging Rust's strong typing and async/await syntax. The wrangler-legacy example uses JavaScript's event-based model, which may be more familiar to web developers but lacks some of the safety features provided by Rust.

12,783

Develop. Preview. Ship.

Pros of Vercel

  • More comprehensive deployment platform supporting multiple frameworks and languages
  • Integrated analytics and performance monitoring tools
  • Larger ecosystem with extensive documentation and community support

Cons of Vercel

  • Potentially more complex setup for simple projects
  • Less focus on edge computing compared to Cloudflare Workers

Code Comparison

Vercel deployment configuration (vercel.json):

{
  "version": 2,
  "builds": [{ "src": "*.js", "use": "@vercel/node" }],
  "routes": [{ "src": "/(.*)", "dest": "/" }]
}

Wrangler configuration (wrangler.toml):

name = "my-worker"
type = "javascript"
account_id = "your-account-id"
workers_dev = true
route = ""
zone_id = ""

Summary

Vercel offers a more comprehensive platform with support for various frameworks and integrated tools, making it suitable for complex projects. Wrangler-legacy, focused on Cloudflare Workers, provides a simpler approach for edge computing. The choice between them depends on project requirements, with Vercel excelling in full-stack deployments and Wrangler-legacy specializing in edge computing scenarios.

1,576

Netlify Command Line Interface

Pros of Netlify CLI

  • More comprehensive feature set, including site management, DNS configuration, and form handling
  • Better documentation and community support
  • Supports a wider range of static site generators and frameworks

Cons of Netlify CLI

  • Steeper learning curve due to more complex functionality
  • May be overkill for simple projects that don't require advanced features

Code Comparison

Netlify CLI (deploying a site):

netlify deploy --prod

Wrangler Legacy (deploying a worker):

wrangler publish

Both CLIs offer simple deployment commands, but Netlify CLI provides more options for customizing the deployment process.

Additional Considerations

  • Wrangler Legacy is specifically designed for Cloudflare Workers, while Netlify CLI is a more general-purpose tool for static site deployment and management
  • Netlify CLI integrates seamlessly with Netlify's hosting platform, while Wrangler Legacy is tailored for Cloudflare's ecosystem
  • Wrangler Legacy has been superseded by the newer Wrangler 2, which offers improved features and compatibility

Overall, choose Netlify CLI for comprehensive static site management and deployment, especially if using Netlify's platform. Opt for Wrangler (preferably the newer version) if working specifically with Cloudflare Workers.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

🤠 wrangler

:stop_sign: This repository is for Wrangler version 1, which is deprecated and no longer updated. This repository is now archived.

New versions of Wrangler are maintained in the Workers SDK repository.


Legacy Documentation

Banner

crates.io   npm   GitHub Actions - Test Status   GitHub Actions - Linter Status  

wrangler is a CLI tool designed for folks who are interested in using Cloudflare Workers.

Wrangler Demo

Installation

You have many options to install wrangler!

For the latest version, see https://github.com/cloudflare/workers-sdk

Install with npm

We strongly recommend you install npm with a Node version manager like nvm, which puts the global node_modules in your home directory to eliminate permissions issues with npm install -g. Distribution-packaged npm installs often use /usr/lib/node_modules (which is root) for globally installed npm packages, and running npm install -g as root prevents wrangler from installing properly.

Once you've installed nvm and configured your system to use the nvm managed node install, run:

npm i @cloudflare/wrangler -g

If you are running an ARM based system (eg Raspberry Pi, Pinebook) you'll need to use the cargo installation method listed below to build wrangler from source.

Specify binary location

In case you need wrangler's npm installer to place the binary in a non-default location (such as when using wrangler in CI), you can use the following configuration options to specify an install location:

  • Environment variable: WRANGLER_INSTALL_PATH
  • NPM configuration: wrangler_install_path

Specify binary site URL

In case you need to store/mirror binaries on premise you will need to specify where wrangler should search for them by providing any of the following:

  • Environment variable: WRANGLER_BINARY_HOST
  • NPM configuration: wrangler_binary_host

Install with cargo

cargo install wrangler

If you don't have cargo or npm installed, you will need to follow these additional instructions.

Install on Windows

perl is an external dependency of crate openssl-sys. If installing wrangler with cargo, you will need to have perl installed. We've tested with Strawberry Perl. If you instead install perl via scoop, you may need to also run scoop install openssl in order to get the necessary openssl dlls. Installing wrangler with npm instead of cargo is another option if you don't want to install perl.

Updating

For information regarding updating Wrangler, click here.

Getting Started

Once you have installed Wrangler, spinning up and deploying your first Worker is easy!

$ wrangler generate my-worker
$ cd my-worker
# update your wrangler.toml with your Cloudflare Account ID
$ wrangler config
$ wrangler publish

🎙️ Top Level Commands

👯 generate

Scaffold a project, including boilerplate code for a Rust library and a Cloudflare Worker.

wrangler generate <name> <template> --type=["webpack", "javascript", "rust"]

All of the arguments and flags to this command are optional:

📥 init

Creates a skeleton wrangler.toml in an existing directory. This can be used as an alternative to generate if you prefer to clone a repository yourself.

wrangler init <name> --type=["webpack", "javascript", "rust"]

All of the arguments and flags to this command are optional:

  • name: defaults to the name of your working directory
  • type: defaults to "webpack".

🦀⚙️ build

Build your project. This command looks at your wrangler.toml file and runs the build steps associated with the "type" declared there.

Additionally, you can configure different environments.

🔓 login

Authorize Wrangler with your Cloudflare login. This will prompt you with a Cloudflare account login page and a permissions consent page. This command is the alternative to wrangler config and it uses OAuth tokens.

wrangler login --scopes-list --scopes <scopes>

All of the arguments and flags to this command are optional:

  • scopes-list: list all the available OAuth scopes with descriptions.
  • scopes: allows to choose your set of OAuth scopes.

Read more about this command in Wrangler Login Documentation.

🔧 config

Authenticate Wrangler with a Cloudflare API Token. This is an interactive command that will prompt you for your API token:

wrangler config
Enter API token:
superlongapitoken

You can also provide your email and global API key (this is not recommended for security reasons):

wrangler config --api-key
Enter email:
testuser@example.com
Enter global API key:
superlongapikey

You can also use environment variables to configure these values.

☁️ 🆙 publish

Publish your Worker to Cloudflare. Several keys in your wrangler.toml determine whether you are publishing to a workers.dev subdomain or your own registered domain, proxied through Cloudflare.

Additionally, you can configure different environments.

You can also use environment variables to handle authentication when you publish a Worker.

# e.g.
CF_API_TOKEN=superlongtoken wrangler publish
# where
# $CF_API_TOKEN -> your Cloudflare API token

CF_API_KEY=superlongapikey CF_EMAIL=testuser@example.com wrangler publish
# where
# $CF_API_KEY -> your Cloudflare API key
# $CF_EMAIL -> your Cloudflare account email

🗂 kv

Interact with your Workers KV store. This is actually a whole suite of subcommands. Read more about in Wrangler KV Documentation.

👂 dev

wrangler dev works very similarly to wrangler preview except that instead of opening your browser to preview your worker, it will start a server on localhost that will execute your worker on incoming HTTP requests. From there you can use cURL, Postman, your browser, or any other HTTP client to test the behavior of your worker before publishing it.

You should run wrangler dev from your worker directory, and if your worker makes any requests to a backend, you should specify the host with --host example.com.

From here you should be able to send HTTP requests to localhost:8787 along with any headers and paths, and your worker should execute as expected. Additionally, you should see console.log messages and exceptions appearing in your terminal.

👂 Listening on http://localhost:8787
[2020-02-18 19:37:08] GET example.com/ HTTP/1.1 200 OK

All of the arguments and flags to this command are optional:

  • env: environment to build
  • host: domain to test behind your worker. defaults to example.com
  • ip: ip to listen on. defaults to localhost
  • port: port to listen on. defaults to 8787

Additional Documentation

All information regarding wrangler or Cloudflare Workers is located in the Cloudflare Workers Developer Docs. This includes:

  • Using wrangler commands
  • Wrangler configuration
  • General documentation surrounding Workers development
  • All wrangler features such as Workers Sites and KV

✨Workers Sites

To learn about deploying static assets using wrangler, see the Workers Sites Quickstart.

NPM DownloadsLast 30 Days