Client-side its easy, you can use window.location.hostname
in router or somewhere else and parse it to get your username. You can also use it as a variable in subscriptions etc. and pass it to server.
Just remember that changing hostname will require full page reload, so it wont be very user-friendly.