Deploy the frontend of your dapp on-chain
On this page
This topic provides a detailed guide on deploying a frontend application into the blockchain. It includes steps for configuring environment variables, building and packaging the application, updating the blockchain settings, and accessing the deployed application through a web interface.
Prerequisites
- A dapp should be ready for the deployment.
- The dapp should be placed into the root of the frontend application file structure. An example can be found here.
Steps to deploy
-
Run the node to get the
blockchainRidvalue, it can be found in the terminal of dapp logs.Terminalchr node start --wipe -
Set the
.envfile by updatingNEXT_PUBLIC_BRIDto the newblockchainRidvalue. -
Replace the empty Next.js configuration with the following:
TypeScriptconst nextConfig = { output: "export", images: { unoptimized: true }, basePath: `/web_query/${process.env.NEXT_PUBLIC_BRID}/web_static`, }; -
Build the frontend and package it using the command:
Terminalpnpm build -
Add
webStaticto yourrell/chromia.ymlfile as shown below:
blockchains:
asset_management:
webStatic: out # this attribute-
Update the blockchain to enable new queries by running:
Terminalchr node update -
Navigate to the following URL to interact with your deployed webpage:
HTTPhttp://localhost:7740/web_query/<blockchainRid>/web_static
To learn more about developing production-ready dapps, visit the Chromia course page.