Introduction
Recently, I was working in a TypeScript project building a SPA application on top of Office 365 and I needed to get the current domain, current site collection and current site urls for using them in a different React components.
The case is we always rely on _spPageContextInfo to get this information, but in fact, we can use window.location object to build the urls as a fallback in case we need to use this Utils library before SP.js loaded or in other context.
Code
Here is my solution for that problem using TypeScript:
All articles in this blog are licensed under CC BY-SA 4.0 unless stating additionally.