State Management and Multiplayer Networking for Turn-Based Games
I would highly recommend checking out https://boardgame.io/ - its a JS library for turn based games, the documentation describes some of these concepts. It uses websockets. I have tried it out myself with my own game prototype, and it is very quick to get up and running with a multiplayer game that you can play from multiple devices in the browser, which sounds exactly like what you want. You use the library with a "game" object which is run server side and contains the game logic, and a "board" which is the game view that the clients see. Since it is a JS library, you should be able to slot in your p5.js board with absolute ease (some of the examples use Three.js).
Realtime application framework (Node.JS server)
With a backend, you should prefer websockets for normal in-game communication and REST API for other communication like authorizing the players, etc. socket.io is a really popular library for implementing websockets.
Appwrite - The Open Source Firebase alternative introduces iOS support . Appwrite is an open source backend server that helps you build native iOS applications much faster with realtime APIs for authentication, databases, files storage, cloud functions and much more!
Simple peer-to-peer with WebRTC
Without backend, you can choose WebRTC for all communication b/w players. peerjs is a good library for that. However, I would still suggest not to take this approach as it can be overwhelming.
Networking of a Turn-Based Game
2 projects | news.ycombinator.com | 15 Feb 2022
How should I learn to make a multiplayer web game?
2 projects | reddit.com/r/AskProgramming | 17 May 2022
How do you manage game state for browser-based game? JS advice helpful.
3 projects | reddit.com/r/gamedev | 17 Mar 2022
PeerJS - Simple peer-to-peer with WebRTC
1 project | reddit.com/r/opensource | 23 Feb 2022
Switching from ws to socket.io to make development faster