One service model.
Unity or the web.
Structure your application as services: units of logic with a lifecycle, explicit dependencies and a home that is not a scene. Write against the model once. Ship it in C# for Unity, or in TypeScript for React, three.js, Babylon.js and Meta IWSDK.
Dependencies you can see
A service declares what it needs in its constructor. The manager builds in order, or tells you what is missing.
Swap the implementation
A different service per platform, chosen at registration. The code that uses it never changes.
Test it like plain code
Construct the service, hand it a fake dependency, assert. No scene, no play mode, no browser.
Unity (C#)
Profiles as ScriptableObjects, a service wizard, a platform switcher and a live view of running services. Unity 6 or newer, from OpenUPM.
Start with Unity →Web (TypeScript)
A core npm package plus a thin connector for React, three.js, Babylon.js or Meta IWSDK. Services run unchanged on every host.
Start on the web →