React Router has introduced “route middleware”, which “are functions that can inspect the request before the app runs and modify the response after the app is ready to respond” (RFC): remix-run/react-router#12941
using route middleware to instantiate the auth and session classes and make it available via context (getLoadContext) and to then handle committing the session and persisting it via the Set-Cookie header will mean no more need to do those things in two separate places between dev and prod.
note that this will also require adopting the new RR context API (which will eventually need to be adopted regardless).