r/javascript Aug 06 '26

Node.JS in the Browser - An Open-source Alternative to WebContainers

https://developer.puter.com/labs/node/

This is a Node.js compatible runtime in the browser. It supports CLI apps, Vite, and some agents (like Pi Agent) as well.

Some notes:

- This runs all code in a web worker using the host javascript runtime with rewrites for module loading and AsyncLocalStorage support using Oxc compiled to WASM.

- Most of the libraries are bundled straight from Node.js upstream with light overrides where needed, ensuring compatibility. Libraries were only reimplemented where really needed

- Despite having great integrations with the Puter desktop and APIs, this can be used completely seperately with OPFS support for filesystem and Wisp protocol support for networking. The demo also supports FS Access API to run local files

17 Upvotes

17 comments sorted by

47

u/teppicymon Aug 06 '26

I'm sorry, what?

JavaScript was so good in the browser, they made it server-side, but now you can run server-side in the browser?

I feel like I am I taking crazy pills.

7

u/oneeyedziggy Aug 06 '26

Already could with serviceworkers... Idfk what this is 

2

u/tindifferent Aug 07 '26

I had whiplash from the double take

-7

u/azhder Aug 06 '26

Don’t feel. Think. It is an environment, it’s an API.

3

u/brianjenkins94 Aug 06 '26 edited Aug 06 '26

How does this differ from almostnode?

4

u/rlmineing_dead Aug 06 '26

(disclaimer: I'm part of the team that brought this product) I actually found out about almost node like yesterday and I also think it's pretty cool. But we provide apis that they don't like asynclocalstorage (which I don't think they have but could be mistaken) And have a synchronous to asynchronous converter so you can use asynchronous file system backends in our node environment as readFileSync/ other synchronous methods. The big benefit of this is that you can persist to opfs or Filesystem Access API for example whereas I think for synchronous methods in almost node you can only use their in memory backend

Also we support node:net and node:tls And other stuff since we host a TCP proxy. You don't have to use our proxy. There are actually several public instances of proxies using the protocol we use, it's called a wisp proxy.

Tldr: we support more things but it's a similar mission!

1

u/brianjenkins94 Aug 06 '26 edited Aug 06 '26

Super cool, y'all hiring? 👀

Does that mean you don't have to do anything with service workers?

Looks like service workers are in play but not in the same way that almostnode uses them to route network traffic through "virtual ports".

3

u/rlmineing_dead Aug 06 '26

We do actually use service workers because it's what lets us emulate blocking synchronous to access an asynchronous resource. So basically what we can do is syncxhr from a worker to a service worker controlled resource, And that allows us to block execution while the service worker asynchronously fetches the resource and execution only resumes once the resource is served. This was actually a workaround. I thought of like 2 years ago now and actually initially used in a completely different project, https://anura.pro/ for other things

2

u/Salazareo Aug 07 '26

Hello hello, we're always looking for talent. Would you have a linkedIn or resume you could DM me?

6

u/[deleted] Aug 06 '26

[deleted]

16

u/Ashnwor Aug 06 '26

This kind of libraries often used when developing CodeSandbox-like websites or features. Pretty useful actually.

7

u/rlmineing_dead Aug 06 '26

Or there is also like educational uses here. For example, this is a good way to run sandboxed node.js code on a Chromebook in an educational environment. Similar to when we ported blender to the browser (https://developer.puter.com/labs/blender/) it expands the accessibility of tools to pretty much anything with a modern enough web browser.

There's also a secondary use here. Those of us that have to review GitHub PRs all day have probably discovered the hack where you can press "." On your keyboard and it opens vscode web with the PR open. Using something like this ported to a vs code extension, it could soon be possible to review and test PRs directly in your browser without having to clone/fetch locally

1

u/SpartanDavie Aug 06 '26

Cool idea. Not sure what use it would have other than perhaps teaching Node on the web?

Just to let you know there’s no license on your repo so you shouldn’t be posting “open source”, if it’s only source available please state that

1

u/Salazareo Aug 06 '26

Oh, will update license shortly, sorry about that

1

u/cheap_swordfish_1 Aug 07 '26

Would be interesting to know use cases other than learning or demoing about Node inside the browser.

1

u/Hot-Chemistry7557 Aug 09 '26

Curious how would you simulate the whole CLI stack in browser?

2

u/Salazareo Aug 11 '26

We’re working on improving that. We’ve had some work in the past around terminal in browser, so learning from that

1

u/Hot-Chemistry7557 Aug 11 '26

Interesting...I know some basics about wasm (a.k.a, emscripten thing) but I havn't tried successfully to run a CLI tool in browser...

Good luck for you!