This project was bootstrapped with Vite.
The MultiversX dApp Template, built using React.js and Typescript. It's a basic implementation of @multiversx/sdk-dapp, providing the basics for MultiversX authentication and TX signing.
See Dapp template for live demo.
- Node.js version 16.20.0+
- pnpm version 8.19.4+
From a terminal, navigate to the project folder and run:
pnpm install
In the project folder run:
pnpm start-devnet
pnpm start-testnet
pnpm start-mainnet
This will start the React app in development mode, using the configs found in the vite.config.ts
file.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
MUST configure hosts file for passkey functionality:
# Add to /etc/hosts (macOS/Linux) or C:\Windows\System32\drivers\etc\hosts (Windows):
127.0.0.1 localhost.multiversx.com
# Edit hosts file:
# macOS/Linux:
sudo nano /etc/hosts
# Windows (run as Administrator):
notepad C:\Windows\System32\drivers\etc\hosts
CRITICAL: WebAuthn requires valid HTTPS certificates to prevent TLS certificate errors:
# Install mkcert (if not already installed)
brew install mkcert
# Install the local CA in your system trust store
mkcert -install
# Generate certificates for localhost.multiversx.com
mkcert localhost.multiversx.com localhost 127.0.0.1 ::1
This creates two files in certificates
folder:
localhost.multiversx.com+3.pem
(certificate)localhost.multiversx.com+3-key.pem
(private key)
Update vite.config.ts to use port 443:
import fs from 'fs';
// import basicSsl from '@vitejs/plugin-basic-ssl'; // Remove this - use mkcert certificates instead
const https = {
key: fs.readFileSync('./certificates/localhost.multiversx.com-key.pem'),
cert: fs.readFileSync('./certificates/localhost.multiversx.com.pem')
};
export default defineConfig({
server: {
port: Number(process.env.PORT) || 443,
strictPort: true,
https,
host: true
}
});
With proper certificates, you can use regular Chrome. For additional debugging, use Chrome with security flags:
# Close all Chrome instances first, then run:
open -a Google\ Chrome --args --ignore-certificate-errors --ignore-urlfetcher-cert-requests --disable-web-security --user-data-dir=/tmp/chrome_dev_passkey
pnpm start-devnet --force
Test URLs:
- Template dApp: https://localhost.multiversx.com
If you encounter NotAllowedError: WebAuthn is not supported on sites with TLS certificate errors
, ensure:
- ✅ mkcert is installed and CA is trusted (
mkcert -install
) - ✅ Certificates are generated for localhost.multiversx.com
- ✅ vite.config.ts uses the certificate files
- ✅ Browser shows a valid HTTPS lock icon
- ✅ No mixed content warnings in DevTools
In the project directory, you can run:
Runs the app in the development mode.
For passkey testing: Run with pnpm start
and open https://localhost.multiversx.com to view it in the browser.
The page will reload if you make edits. You will also see any lint errors in the console.
Launches the test runner in the interactive watch mode. See the section about running tests for more information.
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes. Your app is ready to be deployed!
See the section about deployment for more information.
A build of the app is necessary to deploy for testing purposes or for production use. To build the project run:
pnpm build-devnet
pnpm build-testnet
pnpm build-mainnet
This template comes with three built-in themes:
- TealLab (mvx:dark-theme)
- VibeMode (mvx:vibe-theme)
- BrightLight (mvx:light-theme)
But you can customize the appearance of your project by defining your own theme using CSS variables. Follow these steps to set it up.
This is the main place where you customize your theme. You add your project specific colors and update CSS variables that style your elements, according to your theme.
Define your color palette in the :root
section:
:root {
--mvx-custom-primary-color: #your-color;
--mvx-custom-secondary-color: #your-color;
}
Next, configure your theme-specific variables:
:root[data-mvx-theme='mvx:your-theme'],
[data-mvx-theme='mvx:your-theme'] {
--mvx-bg-color-primary: var(--mvx-custom-primary-color);
--mvx-bg-color-secondary: var(--mvx-custom-secondary-color);
}
This hook registers and manages all available themes in your project.
It maintains a list of all theme options, tracks the currently active theme and
provides a handleThemeSwitch
function that updates the data-mvx-theme
attribute.
const allThemeOptions: ThemeOptionType[] =
[
{ identifier: 'mvx:dark-theme', label: 'TealLab' },
{ identifier: 'mvx:vibe-theme', label: 'VibeMode' },
{ identifier: 'mvx:light-theme', label: 'BrightLight' },
{ identifier: 'mvx:your-theme', label: 'Your Theme Label' }
];
This allows you to see the theme options available in the project. They are listed in a tooltip dropdown in header with visual color previews for each theme.
const themeDotColors: Record<string, string[]> =
{
'mvx:dark-theme': ['#23F7DD', '#262626', '#B6B3AF', '#FFFFFF'],
'mvx:vibe-theme': ['#471150', '#5A2A62', '#D200FA', '#FFFFFF'],
'mvx:light-theme': ['#000000', '#A5A5A5', '#E2DEDC', '#F3EFED'],
'mvx:your-theme': ['#color1', '#color2', '#color3', '#color4']
};
Add your icon in assets
folder and import it as:
import { ReactComponent as YourThemeIcon } from 'assets/icons/your-theme-icon.svg';
Add a background image for your theme in public
folder and reference it in tailwind.css
:
@theme {
--background-image-your-theme: url('/your-theme-bg.png');
}
And then update themeExtraProperties
object with your values. These properties are used for
customizing your hero section from home page. It adds background image and icon + title for the
theme switch section in hero.
const themeExtraProperties: Record<
string,
Omit<HomeThemeOptionType, keyof ThemeOptionType>
> = {
// existing themes
'mvx:your-theme': {
icon: YourThemeIcon,
title: 'Your Title',
backgroundClass: 'bg-your-theme'
}
};
dAppConfig: {
theme: 'mvx:your-theme',
}
Now the project will start with your configured theme.
All variables will have the colors you have set. If you don't set custom colors, the default ones will apply.
You can see the current theme in data-mvx-theme
attribute in browser inspector.
You can learn more in the Vite documentation.
To learn React, check out the React documentation.
See the open issues for a list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
One can contribute by creating pull requests, or by opening issues for discovered bugs or desired features.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request