"nx.js" - JavaScript runtime for Nintendo Switch homebrew applications

Hello all, I'm feeling like it's time to share the nights / weekends project that I've been working on for the past few months: nx.js

logo.png

nx.js is runtime which enables Nintendo Switch homebrew applications to be written in JavaScript (or anything that compiles to JavaScript, but specifically TypeScript). The idea stems from the desire to port some existing web-based games written in JavaScript over to Nintendo Switch. nx.js focuses on implementing web-based standards that would be useful for a homebrew application, such as the web Canvas API for drawing to the screen, and fetch() for interacting with HTTP servers. Access to the Switch-specific hardware is implemented via the global Switch object, like handling controller and touchscreen inputs, vibrating the controller, and reading / writing files to the SD card. I think it could also be useful for anyone who is interested in creating a homebrew application, but might be intimidated by writing the C code and tooling necessary to get it working.

I was able to port the popular 2048 game, which is a web-based JavaScript game, to be a Switch homebrew app and I'm pretty happy with the result so far. It still needs some polish on the rendering, but the core game mechanics work great without any modification to the original game engine code:


Download "2048.nro" file


Another fun example is rendering the classic Star Wars ASCII text to the screen, by connecting to a telnet server which streams the data over the network:


Download "starwars.nro" file


If you'd like to play around on your own, then there's a bootstrapping utility to get you started. You can pick from one of the example applications and then modify from there. First, make sure you have Node.js installed for the tooling, and then run the following command in your terminal:

Bash:
npm create nxjs-app@latest

create-nxjs-app.png


The example applications are configured to compile the code using esbuild. Applications can then be packaged up into a self-contained NRO file, including custom icon image, title, author, version, and RomFS filesystem for additional assets required for the application (images, custom fonts, etc.) using the nxjs-pack command.

Anyways, nx.js is still in the early development phase from my point of view, but I think it's reached a point where I wanted to get it out there and start getting feedback. It's been fun for me to develop so far and learn some of the in-and-outs of developing Switch homebrew applications, and my hope is that some of the more tricky / nuanced parts can be abstracted out into intuitive and fun / familiar to use APIs for JavaScript apps to utilize going forward.

Let me know what you think! If you would like to get involved in the development of the runtime, or would like help in developing an application using nx.js, come join the Discord server and say hi.

Cheers! 🍻
 
Last edited by tootallnate,

DragonMals

6th-7th Gen Retro Gaming Entusiast
Member
Joined
Sep 23, 2022
Messages
726
Trophies
1
Location
XP
2,554
Country
United States
This is mad excellent. Great to see the hombrew scene for the Switch striving! Cant wait until the Switch us discontinue so we can see its full potential :)
 
  • Like
Reactions: dudeguy2022

leerz

Well-Known Member
Member
Joined
Jan 11, 2015
Messages
754
Trophies
0
Age
36
Location
Makati
Website
leerz25.sitesled.com
XP
2,193
Country
Hello all, I'm feeling like it's time to share the nights / weekends project that I've been working on for the past few months: nx.js

View attachment 392274
nx.js is runtime which enables Nintendo Switch homebrew applications to be written in JavaScript (or anything that compiles to JavaScript, but specifically TypeScript). The idea stems from the desire to port some existing web-based games written in JavaScript over to Nintendo Switch. nx.js focuses on implementing web-based standards that would be useful for a homebrew application, such as the web Canvas API for drawing to the screen, and fetch() for interacting with HTTP servers. Access to the Switch-specific hardware is implemented via the global Switch object, like handling controller and touchscreen inputs, vibrating the controller, and reading / writing files to the SD card. I think it could also be useful for anyone who is interested in creating a homebrew application, but might be intimidated by writing the C code and tooling necessary to get it working.

I was able to port the popular 2048 game, which is a web-based JavaScript game, to be a Switch homebrew app and I'm pretty happy with the result so far. It still needs some polish on the rendering, but the core game mechanics work great without any modification to the original game engine code:

View attachment 392275

Download "2048.nro" file


Another fun example is rendering the classic Star Wars ASCII text to the screen, by connecting to a telnet server which streams the data over the network:

View attachment 392276

Download "starwars.nro" file


If you'd like to play around on your own, then there's a bootstrapping utility to get you started. You can pick from one of the example applications and then modify from there. First, make sure you have Node.js installed for the tooling, and then run the following command in your terminal:

Bash:
npm create nxjs-app@latest

View attachment 392277

The example applications are configured to compile the code using esbuild. Applications can then be packaged up into a self-contained NRO file, including custom icon image, title, author, version, and RomFS filesystem for additional assets required for the application (images, custom fonts, etc.) using the nxjs-pack command.

Anyways, nx.js is still in the early development phase from my point of view, but I think it's reached a point where I wanted to get it out there and start getting feedback. It's been fun for me to develop so far and learn some of the in-and-outs of developing Switch homebrew applications, and my hope is that some of the more tricky / nuanced parts can be abstracted out into intuitive and fun / familiar to use APIs for JavaScript apps to utilize going forward.

Let me know what you think! If there's interest for this kind of thing, perhaps I'll make a Discord server where we could hack and develop this runtime further.

Cheers! 🍻
new world of homebrew is unlocked with this. amazing job!
 
  • Like
Reactions: shaunj66

AndorfRequissa

Well-Known Member
Member
Joined
Sep 8, 2019
Messages
191
Trophies
0
Age
40
XP
529
Country
United States
this is awesome. do you plan on updating the UI in the future of your homebrew so that games developed using this script are launched inside this app or once installed will people have additional capabilities when creating their own .nsp or folder installs?
 
  • Like
Reactions: DragonMals

TheStonedModder

Well-Known Member
Member
Joined
Dec 25, 2022
Messages
856
Trophies
0
Age
27
XP
1,680
Country
United States
This is super cool! I used to use the Lua interpreter for ps vita homebrew and was really hoping the Python switch one would have made more progress

But this is still super neat and an excuse to learn JS! Great job I’m going to mess with it later on
 
  • Like
Reactions: DragonMals

XRTerra

What if instead of ohio, it was kai cenat land
Member
Joined
Jul 1, 2022
Messages
228
Trophies
0
Location
United States of America
XP
549
Country
United States
This could open the door to so many useful apps and fun games.

For example, perhaps a javascript rom downloader that pulls directly from any specific site. Would be nice not to need my pc/phone whenever I want to play a different retro game.
 

tootallnate

Developer
OP
Developer
Joined
Mar 31, 2023
Messages
58
Trophies
0
Age
35
Website
n8.io
XP
459
Country
United States
This is very nice.
Now if only someone would revive PyNX...

I actually got inspired to create nx.js after seeing PyNX!

Amazing. We had a similar thing in the very beginning of the switch hacking days but it has been abandoned pretty quickly:
https://gbatemp.net/threads/brew-js-make-homebrew-apps-with-javascript.504327/
Great not only to see another (and probably better) take on it but in general that something new in the homebrew scene is happening.

I saw this one as well while investigating if there was any prior art on this idea. brew.js looked more low-level and, ya, abandoned. I think nx.js could shine in comparison by having nicer APIs and tooling.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • SylverReZ @ SylverReZ:
    @Xdqwerty, Hello, my friend.
    +1
  • Xdqwerty @ Xdqwerty:
    @SylverReZ, I lost an online friend today who i knew since 2021
  • SylverReZ @ SylverReZ:
    @Xdqwerty, I'm sorry to hear that.
    +1
  • Xdqwerty @ Xdqwerty:
    @SylverReZ, He said that my actitude was "cutty" and that our friendship wasnt going anywhere
  • SylverReZ @ SylverReZ:
    @Xdqwerty, You're not like that. I see you as a really kind individual.
    +1
  • BigOnYa @ BigOnYa:
    Sounds like you are better off than having a petty friend like that anyways. You win today.
    +2
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, but both of us were fine yesterday
  • BakerMan @ BakerMan:
    ah well, at least you got us (sorry if this sounds like some cornball ass "power of friendship" stuff)
    +3
  • K3Nv2 @ K3Nv2:
    Kind of hyped about the new ally finally a portable with full m.2 support
  • BigOnYa @ BigOnYa:
    Kinda reminds me of a life lesson in the movie "Bronx Tale". Guy1 owes another, guy2 $10 and the guy2 keeps chasing guy1 around the city trying to get his money back, till someone tells him, "stop, you got off easy, its only $10. That guy will never bother you again or ask you for money again, so take it as a win."
    +1
  • K3Nv2 @ K3Nv2:
    Guy1 will continue to talk shit about you constantly as well
  • K3Nv2 @ K3Nv2:
    Because he knows what he did
  • BigOnYa @ BigOnYa:
    Speaking of which, where is my $10 Ken? And I heard you been talking crap bout me to my wife. Punk.
  • K3Nv2 @ K3Nv2:
    You were standing right there when we were talking should've said something then
    +1
  • BigOnYa @ BigOnYa:
    Lol
  • K3Nv2 @ K3Nv2:
    Fucking insurance gave me a migraine told me my dentist was in network now they're rejecting claims saying they aren't
  • BigOnYa @ BigOnYa:
    That's what they do the best, pass the buck.
  • Xdqwerty @ Xdqwerty:
    wut
  • K3Nv2 @ K3Nv2:
    Insurance is a thing adults have to blow off
  • BigOnYa @ BigOnYa:
    Insurance is one those things you pay all your life for, no questions asked, all is fine, they take your money. And as soon as you make a claim or something happens, they never want to payout or help, just fight you on everything if it cost them any of your money.
  • BigOnYa @ BigOnYa:
    I've never had a car accident, but I bet I've paid thousands/ million into car insurance that ill never see a dime of prob. Is crazy, but its the law.
    BigOnYa @ BigOnYa: I've never had a car accident, but I bet I've paid thousands/ million into car insurance that...