I haven't migrated off of Firebase but this is something I've thought a lot about as I've selected Firebase for many of my client projects.
As far as I can tell there is no open-source alternative with feature parity that makes it easy to migrate away from Firebase. I'd be curious to hear about how people have done this.