Create custom domain/url for each customer

Hi Folks,
Could someone explain how do site like Slack/Wordpress creates cutom URL for each user/team.
Any leads will be highly appreciated…Thanks!

The first thing you need is a wildcard DNS record.

As per WikiPedia

A wildcard DNS record is a record in a DNS zone that will match requests for non-existent domain names. A wildcard DNS record is specified by using a “*” as the leftmost label (part) of a domain name, e.g. *

Next, you need to point that record to a script that reads the URL and loads the appropriate content for the given user identified in the first part of the URL.