Is it possible to use some SPA framework such as react?

Game development with Board Game Arena Studio
Post Reply
User avatar
YEEDA
Posts: 11
Joined: 28 October 2016, 09:32

Is it possible to use some SPA framework such as react?

Post by YEEDA »

Is it possible to use some SPA framework such as react?

I already finished a game by using pure js to manipulate the DOM directly.

I am planning to learn a single-page application framework (react).
And I wonder is it possible to use those framework to render the game on bga?

If it is possible, what is the minimal example looks like?
User avatar
Tisaac
Posts: 2350
Joined: 26 August 2014, 21:28

Re: Is it possible to use some SPA framework such as react?

Post by Tisaac »

YEEDA wrote: 20 September 2022, 19:42 Is it possible to use some SPA framework such as react?

I already finished a game by using pure js to manipulate the DOM directly.

I am planning to learn a single-page application framework (react).
And I wonder is it possible to use those framework to render the game on bga?

If it is possible, what is the minimal example looks like?
Short answer : no.
Long answer : at least two devs (including myself) experimented VueJs which is the easiest one to integrate into this kind of website and we wouldnt recommend doing that.
User avatar
YEEDA
Posts: 11
Joined: 28 October 2016, 09:32

Re: Is it possible to use some SPA framework such as react?

Post by YEEDA »

Tisaac wrote: 20 September 2022, 22:42
YEEDA wrote: 20 September 2022, 19:42 Is it possible to use some SPA framework such as react?

I already finished a game by using pure js to manipulate the DOM directly.

I am planning to learn a single-page application framework (react).
And I wonder is it possible to use those framework to render the game on bga?

If it is possible, what is the minimal example looks like?
Short answer : no.
Long answer : at least two devs (including myself) experimented VueJs which is the easiest one to integrate into this kind of website and we wouldnt recommend doing that.
So Sad :(
User avatar
Victoria_La
Posts: 620
Joined: 28 December 2015, 20:55

Re: Is it possible to use some SPA framework such as react?

Post by Victoria_La »

I would say it is possible, but not practical.
I managed to get working template using typescript classes, which took me days of hitting head on the wall dealing with dojo.
https://github.com/elaskavaia/bga-dojoless

Its not far fetch to add more processors/webpack to get core react, you have hack it to deal with ajax and comet notification some-how,
but not sure it will make wrtiting game easier even if you get it going...
User avatar
Een
Posts: 3854
Joined: 16 June 2010, 19:52

Re: Is it possible to use some SPA framework such as react?

Post by Een »

Also please remember that the most likely reason for a game to be broken by a framework update then abandoned is to add in some specific "creative" code layer or external dependencies that may be hard to maintain.

There is a lot of freedom in the way you can program your game module, but it also means that you can back yourself into a corner. It has happened before.
User avatar
Tof63
Posts: 135
Joined: 24 March 2020, 20:25

Re: Is it possible to use some SPA framework such as react?

Post by Tof63 »

I'm a bit late to answer maybe, but the game I developed uses React for some parts.

https://studio.boardgamearena.com/studi ... reflection

The game board is composed in large part of a grid displaying mirrors and a laser, this part is developed in React. Everything else is developed in a "classic" way following the bga tutorials, and the interactions between the two are minimal.

The complete code of the project can be seen here : https://github.com/cdelaforge/reflection

I'm not really proud of the php part, I really don't like this language :p
And some things in javascript are certainly optimizable too, but the React part is pretty clean I think :)

The choice I made was probably debatable, and certainly not suitable for the vast majority of games on the site, but I'm convinced I saved a lot of time by doing this for the particular case of this game: it simplifies the code a lot.
User avatar
YEEDA
Posts: 11
Joined: 28 October 2016, 09:32

Re: Is it possible to use some SPA framework such as react?

Post by YEEDA »

Tof63 wrote: 11 October 2022, 14:31 I'm a bit late to answer maybe, but the game I developed uses React for some parts.

https://studio.boardgamearena.com/studi ... reflection

The game board is composed in large part of a grid displaying mirrors and a laser, this part is developed in React. Everything else is developed in a "classic" way following the bga tutorials, and the interactions between the two are minimal.

The complete code of the project can be seen here : https://github.com/cdelaforge/reflection

I'm not really proud of the php part, I really don't like this language :p
And some things in javascript are certainly optimizable too, but the React part is pretty clean I think :)

The choice I made was probably debatable, and certainly not suitable for the vast majority of games on the site, but I'm convinced I saved a lot of time by doing this for the particular case of this game: it simplifies the code a lot.
Not late!
Thanks for your reply!

Now I know how to combine npm files to the bga framework.
By the way, the official react tutorial not work for bga even if I upload the source code to the server.
https://beta.reactjs.org/learn/add-react-to-a-website
Post Reply

Return to “Developers”