Using ReactJS for games on Itch.io


Question: How do I upload a react app to itch.io?

Answer: Host it somewhere else, and stick it in an IFrame.


Long version:

I'm a developer that uses React for front-end development in my day job. One weekend, I was inspired by the jamcraft gamejam to make a ui-heavy game. Initially, I tried making the game with Unity. It didn't take me long to realise that I was wasting my time implementing stuff that JavaScript, html, and css would give me for free -- especially when used with a modern framework like React. 

I knew I wanted to use React. What I didn't know was how I would upload the game to itch.io and enter the gamejam. I tried just uploading it as I would a vanilla js project, but that didn't work (no surprises there) . I tried googling, but the instructions on how to make a 'static' react app with all the routes set up were really complicated, and I just wanted to get on with the game. 

So, I went with something I knew would work: host the app somewhere else, and upload an index file that just has an IFrame pointing to it. 

The simplest solution would be just to run "yarn start", which would start the app running on my local computer, as I do during development. Then I could put my own IP address with the right port number, and it would work! ... until I turned off my computer. 

The next most obvious thing to me would be to host it with AWS. This would be the professional approach, and what I would do if I expected more than a handful of people to play the game. However, the gamejam specified that only free tools available to everyone would be allowed, and, even though the usage would certainly fit within the free tier, AWS didn't seem in the spirit of the jam. Plus, fiddling with sever settings would probably be overkill for what I wanted. 

I ended up going with now.sh. I can't speak for the reliability of their hosting service, but the ease of use makes it perfect for prototypes and gamejams. I dunno what kind of magic they use, but all I did after installing was type `now` from my project file, and they deployed it for me! I had to set up an alias so the url would stay consistent, but it worked fine!  

You can see the version of my app deployed on now.sh here: https://jamcraft-entry.bethanyd.now.sh/

And the version in the iframe here: https://bethanydrake.itch.io/jamcraft-entry

Comments

Log in with itch.io to leave a comment.

Thanks for this! I just used it to post 2 of my games!

Nice solution! I suppose I might have to do the same for my Angular game.