Embed Cloudflare Workers IDE within our SaaS app

We would like our users to be able to use the Cloudflare Workers IDE to write and test Workers code in our own app. Is that possible?

The use case is simple - we are using Workers to run custom validation rules in JS e.g. if you update a form field - it must contain 16 characters and 3 upper-case letters. Basically - it’s custom validation.

To do this - our idea was simple - let our users write Worker-ready/compliant code so that we can wrap that code and run it as a Worker.

Instead of our users going to Cloudflare and setting up a dummy account, just to edit JS and test their Worker (which lives on our domain anyway) - can we “embed” or wrap the Workers IDE - i.e. the one below - into our own app - so that our users write custom functions, but can still gain the benefits of the IDE/testing, etc?

We will run and pay for the Worker, but our customers need to write the code on our end, as it makes far more sense (we run code on their behalf). We will likely have moderation before go-live, so not worried about unsafe use at this time.

That wouldn’t be possible and would change entirely how Workers and Cloudflare Dashboard works.

However, there’s a solution to doing this and we’re currently doing this ourselves.

What you’ll need:

  1. Github or Gitlab account.
  2. A worker function which can upload a source file to Git via API.
  3. Authentication function in the worker (like 0auth) so that clients can login.
  4. A front-end with a code editor added (like Vue/React app)
  5. The App uploads the script file via API and then trigger a Github action or Gitlab CI.
  6. The action will run wrangler publish.
  7. WIN!!

The disadvantage is that debugging will be problematic, but you can have development and production environments in the Git CI/Actions of course.

1 Like

which front end IDE did you bake in? All the debugging stuff, etc. is extensive - as the UI you noted in point (4) above is not just a syntax highlighter.

Why not just upload from using cloudflare api directly? Durable Objects is little bit more complicate, but for regular workers is just few lines of code. I dont use wrangler on my projects btw.

Separation of concerns plus making sure that developers can create their part of the whole app and don’t have access to all of it.

https://ace.c9.io/

1 Like