---
schema_version: "1"
id: 4b54996189b49908ec32b3b88a0cd9ef5ce7a359ffcb5a943ff26bb49097aed2
title: DomainCreator Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_class_System_DomainCreator.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_DomainCreator.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0b907273eac97bdf93399804483604688d961c8834fbf2a49768e2375e70cef9
description: Use the DomainCreator class to return a hostname specific to the org. For example, get the org’s Visualforce hostname. Values are returned as a hostname, such as MyDomainName.lightning.force.com where MyDomainName is a placeholder value.Returns the hostname for content stored in the org, such as files.Returns the hostname to access Experience Builder for the org’s Experience Cloud sites.Returns the system-managed hostname for the org’s Experience Cloud sites, such as ExperienceCloudSitesSubdomainName.force.com, where ExperienceCloudSitesSubdomainName is a placeholder value. If Digital Experiences aren’t enabled, this method throws an InvalidParameterValueException.Returns the hostname to access Experience Builder Live Preview for the org’s Experience Cloud sites.Returns the hostname to access Experience Builder Preview for the org’s Experience Cloud sites.Returns the hostname for the org’s Lightning Container Components.Returns the hostname for the org’s Lightning pages.Returns the hostname for the org’s My Domain login domain.Returns the hostname for the org’s Salesforce Sites. If Salesforce Sites aren’t enabled, this method throws an InvalidParameterValueException.Returns the hostname for the org’s setup domain, which hosts Setup pages in Salesforce. Returns the hostname for the org’s Visualforce pages.
---
# DomainCreator Class

Use the DomainCreator class to return a hostname specific to the org. For example, get the org’s Visualforce hostname. Values are returned as a hostname, such as MyDomainName.lightning.force.com where _MyDomainName_ is a placeholder value.

## Namespace

[System](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_System.htm "The System namespace provides classes and methods for core Apex functionality.")

## Examples

This example code fetches the org’s My Domain login hostname and the Visualforce hostname for the uat package.

//Get the My Domain login hostname
String myDomainHostname = DomainCreator.getOrgMyDomainHostname();

//Get the Visualforce hostname
String vfHostname = DomainCreator.getVisualforceHostname('uat');

In this case, in a production org with a My Domain name of mycompany, myDomainHostname returns mycompany.my.salesforce.com. And in the same production org, vfHostname returns mycompany--uat.vf.force.com.

This example code creates a link to a Salesforce Account record. It gets the Lightning hostname associated with this org. It then gets the Account record ID and uses concatenation to build the link URL.

//Get the org’s Lightning hostname
String myLightningHostname = DomainCreator.getLightningHostname();
 
//Get the ID of a record Account with the name ‘Acme’
Account acct = \[SELECT Id FROM Account WHERE Name = 'Acme' WITH USER\_MODE LIMIT 1\];
 
//Build the URL to view the account record
String fullRecordURL = 'https://' + myLightningHostname + '/lightning/r/Account/' + acct.Id + '/view';

- **[DomainCreator Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_DomainCreator.htm#apex_System_DomainCreator_methods)**

## DomainCreator Methods

The following are methods for DomainCreator.

- **[getContentHostname()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_DomainCreator.htm#apex_System_DomainCreator_getContentHostname)**  
    Returns the hostname for content stored in the org, such as files.
- **[getExperienceCloudSitesBuilderHostname()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_DomainCreator.htm#apex_System_DomainCreator_getExperienceCloudSitesBuilderHostname)**  
    Returns the hostname to access Experience Builder for the org’s Experience Cloud sites.
- **[getExperienceCloudSitesHostname()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_DomainCreator.htm#apex_System_DomainCreator_getExperienceCloudSitesHostname)**  
    Returns the system-managed hostname for the org’s Experience Cloud sites, such as ExperienceCloudSitesSubdomainName.force.com, where _ExperienceCloudSitesSubdomainName_ is a placeholder value. If Digital Experiences aren’t enabled, this method throws an InvalidParameterValueException.
- **[getExperienceCloudSitesLivePreviewHostname()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_DomainCreator.htm#apex_System_DomainCreator_getExperienceCloudSitesLivePreviewHostname)**  
    Returns the hostname to access Experience Builder Live Preview for the org’s Experience Cloud sites.
- **[getExperienceCloudSitesPreviewHostname()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_DomainCreator.htm#apex_System_DomainCreator_getExperienceCloudSitesPreviewHostname)**  
    Returns the hostname to access Experience Builder Preview for the org’s Experience Cloud sites.
- **[getLightningContainerComponentHostname(packageName)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_DomainCreator.htm#apex_System_DomainCreator_getLightningContainerComponentHostname)**  
    Returns the hostname for the org’s Lightning Container Components.
- **[getLightningHostname()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_DomainCreator.htm#apex_System_DomainCreator_getLightningHostname)**  
    Returns the hostname for the org’s Lightning pages.
- **[getOrgMyDomainHostname()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_DomainCreator.htm#apex_System_DomainCreator_getOrgMyDomainHostname)**  
    Returns the hostname for the org’s My Domain login domain.
- **[getSalesforceSitesHostname()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_DomainCreator.htm#apex_System_DomainCreator_getSalesforceSitesHostname)**  
    Returns the hostname for the org’s Salesforce Sites. If Salesforce Sites aren’t enabled, this method throws an InvalidParameterValueException.
- **[getSetupHostname()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_DomainCreator.htm#apex_System_DomainCreator_getSetupHostname)**  
    Returns the hostname for the org’s setup domain, which hosts Setup pages in Salesforce.
- **[getVisualforceHostname(packageName)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_System_DomainCreator.htm#apex_System_DomainCreator_getVisualforceHostname)**  
    Returns the hostname for the org’s Visualforce pages.

### getContentHostname()

Returns the hostname for content stored in the org, such as files.

#### Signature

public static String getContentHostname()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### getExperienceCloudSitesBuilderHostname()

Returns the hostname to access Experience Builder for the org’s Experience Cloud sites.

#### Signature

public static String getExperienceCloudSitesBuilderHostname()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### getExperienceCloudSitesHostname()

Returns the system-managed hostname for the org’s Experience Cloud sites, such as ExperienceCloudSitesSubdomainName.force.com, where _ExperienceCloudSitesSubdomainName_ is a placeholder value. If Digital Experiences aren’t enabled, this method throws an InvalidParameterValueException.

#### Signature

public static String getExperienceCloudSitesHostname()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### getExperienceCloudSitesLivePreviewHostname()

Returns the hostname to access Experience Builder Live Preview for the org’s Experience Cloud sites.

#### Signature

public static String getExperienceCloudSitesLivePreviewHostname()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### getExperienceCloudSitesPreviewHostname()

Returns the hostname to access Experience Builder Preview for the org’s Experience Cloud sites.

#### Signature

public static String getExperienceCloudSitesPreviewHostname()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### getLightningContainerComponentHostname(packageName)

Returns the hostname for the org’s Lightning Container Components.

#### Signature

public static String getLightningContainerComponentHostname(String packageName)

#### Parameters

- **packageName**: Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.") The package name for this component.
    
    If packageName is null, this method uses the org’s namespace prefix as the package name. Otherwise, it uses the default namespace.

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### getLightningHostname()

Returns the hostname for the org’s Lightning pages.

#### Signature

public static String getLightningHostname()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### getOrgMyDomainHostname()

Returns the hostname for the org’s My Domain login domain.

#### Signature

public static String getOrgMyDomainHostname()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### getSalesforceSitesHostname()

Returns the hostname for the org’s Salesforce Sites. If Salesforce Sites aren’t enabled, this method throws an InvalidParameterValueException.

#### Signature

public static String getSalesforceSitesHostname()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### getSetupHostname()

Returns the hostname for the org’s setup domain, which hosts Setup pages in Salesforce.

#### Signature

public static String getSetupHostname()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### getVisualforceHostname(packageName)

Returns the hostname for the org’s Visualforce pages.

#### Signature

public static String getVisualforceHostname(String packageName)

#### Parameters

- **packageName**: Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.") The package name for this component.
    
    If packageName is null, this method uses the org’s namespace prefix as the package name. Otherwise, it uses the default namespace.

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")