"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
687
Trophies
1
Location
XP
2,281
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,180
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
188
Trophies
0
Age
40
XP
512
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
824
Trophies
0
Age
27
XP
1,628
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
457
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
  • No one is chatting at the moment.
    Psionic Roshambo @ Psionic Roshambo: I did use a bot for Diablo III though but no ban there lol