this ^. to add: Identifying a good company is also key. I work for a small startup and am currently the only senior backend developer. I think being 20% of the company and 100% of the backend helped my situation.
If you got a job at a large tech company, I suspect many wouldn't be as flexible. If you want to work for a large tech company, I would find out if they have any current remote workers.