# Connect a client · Chromia Docs (concept)

> This section covers how to connect a frontend or other client to a dapp backend deployed on a Chromia network.

Source: https://docs.chromia.com/build/deployment/mainnet/connect-client/

# Connect a client

This section covers how to connect a frontend or other client to a dapp backend deployed on a Chromia network. The
examples here use the TypeScript-based [`postchain-client`](https://www.npmjs.com/package/postchain-client), but the
principles are the same when using other client libraries.

Available Client Libraries

This guide shows one example using the TypeScript client. For a complete list of available client libraries and their
documentation, see the [Client Libraries Overview](https://docs.chromia.com/build/clients/overview/).

To connect to a deployed dapp, the client library needs a pool of URLs to system nodes in the Chromia network, as well
as the Blockchain RID of the dapp to connect to. The client automatically queries the
[Directory Chain](https://docs.chromia.com/get-started/about/architecture/) on the system nodes to fetch the URLs of all nodes where your dapp is
currently running, thus establishing a connection to the dapp.

1. Ensure you have a dapp deployed on Mainnet. For deployment instructions, see
   [Deploy your dapp to Mainnet](https://docs.chromia.com/build/deployment/mainnet/deploy-dapp/).
2. If you are deploying a frontend created using the
   [Hello World Quickstart](https://docs.chromia.com/build/clients/postchain-clients/javascript-typescript/hello-world-quickstart/), remove the admin
   key pair configuration and replace it with a secure link to your stored key pair. This ensures the security of your
   key pair. For more details on how to build a production-ready dapp, visit the
   [Chromia course page](https://chromia.com/learn/).

   TypeScript

   ```
   // Remove any private keys from your production client code
   const adminPubkey = Buffer.from("<PubkeyLink>", "hex");
   const adminPrivkey = Buffer.from("<PrivkeyLink>", "hex");
   ```
3. Specify URLs of Chromia nodes running the Directory Chain in your client code. For the most recent and complete list,
   visit the [Chromia Explorer](https://explorer.chromia.com/) and view the list of nodes in the **system cluster**.

   TypeScript

   ```
   const directoryNodeUrlPool = [
    "https://system.chromaway.com",
    "https://chromia.validatrium.club",
    "https://chromia-mainnet-systemnode-1.stakin-nodes.com",
    "https://chroma.node.monster:7741",
    "https://dapps0.chromaway.com",
    "https://chromia-mainnet.w3coins.io:7740",
    "https://mainnet-dapp1.sunube.net:7740"
   ];
   ```
4. Establish a connection to your dapp by providing the dapp's Blockchain RID and the system node URLs:

   TypeScript

   ```
   // Connection input
   const blockchainRID = "<BlockchainRID>"; // Target Blockchain RID
   const directoryNodeUrlPool = ["<TargetUrl1>", "<TargetUrl2>", "etc."]; // System node URLs

   // Connection setup
   const chromiaClient = await pcl.creatClient({
     blockchainRID,
     directoryNodeUrlPool,
   });
   ```

   Replace `<BlockchainRID>` with the actual blockchain RID for your dapp, and the `<TargetUrls>` with the appropriate
   Chromia system node URLs from step 3.

With these steps, you have successfully configured `postchain-client` to work with your dapp backend running on the
Chromia network.

To learn more about developing production-ready dapps, visit the [Chromia course page](https://chromia.com/learn/).

[View this page on docs.chromia.com](https://docs.chromia.com/build/deployment/mainnet/connect-client/)Content mirrored from the live docs
