Yep I am using this code and it works. Also MS documentation confirms this
const projectClient = await SDK.getService<IProjectPageService>(CommonServiceIds.ProjectPageService);
const projectContext = await projectClient.getProject();
const hostContext = SDK.getHost();
let organizationId = hostContext.id
let organizationName = hostContext.name
let projectName = projectContext.Name
let url = `https://dev.azure.com/${organizationName}/${projectName}/<whatever you need>`