I saw some code in github set localstorage key like 'user' in the localstorage. I think it should be at least $domain_name + 'user', because that might clash with other app. Am I right?
No. Each origin has it's own namespace. One origin do not have access to other origins' localStorage data.