I’d encourage you to check out the p5.SceneManager. It seems to be built for exactly what you’re trying to accomplish with sequencing sketches together
as for storage, if you use scene manager, you can keep the important things in the global scope and then send them off to the server as needed or use something like store.js to keep it in web storage (or whatever the users browser supports) and then offload that to the server as need be