This guide will walk you through creating and deploying a storefront using the Metaplex platform.
Prerequisites
Before starting, ensure you have:
A basic understanding of React concepts such as hooks. Refer to the React documentation here.
A wallet containing tokens to perform your transactions.
Familiarity with the different packages and their purposes (helpful but not required).
Getting Started
Setting Up the Store ID
To create a store, you first need to derive the store ID using your public wallet address. The Metaplex developers have provided an environment variable for this purpose: REACT_APP_STORE_OWNER_ADDRESS_ADDRESS.
Steps:
Create a .env file in packages/web.
Set REACT_APP_STORE_OWNER_ADDRESS_ADDRESS to your wallet's public address.
After setting up your store ID, you can create your store using Metaplex's helper methods.
Steps:
Use the saveAdmin method located at packages/web/src/actions/saveAdmin.
You can create a script or a button in your UI to call this method.
Example:
For a button in your UI:
Note: Confirm your transactions after clicking the button. Do not navigate away from the page during this process.
Adding Your Information
After creating your store, update your store's information by editing the userNames.json file located at packages/web/src/config/userNames.json. Follow the format used by other objects in this file.
Accessing the Admin Panel
Once your store is set up, you can access the admin panel at YOUR_URL/#/admin. Here, you can manage your store, add whitelisted creators, or make your store public. Ensure you save your changes after editing.
Deploying Your Store
Deploying to GitHub Pages
Step 1: Specify Your Repository
In the js/packages/web/package.json file, update the following lines:
Replace https://github.com/metaplex-foundation/metaplex with your repository URL, and set ASSET_PREFIX to your repository name.
Example:
Step 2: Deploy
Navigate to the js/packages/web directory and run the following command:
Note: If you have 2FA enabled, you'll need to use a personal access token as your password. Follow this guide for more details.
Deploying with a Custom Domain
If using a custom domain, remove the ASSET_PREFIX from the deploy script:
Deploy using the same commands as above.
Deploying to Vercel
To deploy your store to Vercel:
Visit Vercel and create a new project linked to your GitHub repo.
Create a pages/ directory under js.
Configure the project with the following settings:
Framework: Next.js
Root directory:js
Output directory:packages/web/.next
Add REACT_APP_STORE_OWNER_ADDRESS_ADDRESS in the Environment Variables section.
Deploying to Google Cloud Run
To deploy through Google Cloud Run:
Step 1: Prepare Your Docker Container
In the Dockerfile, set ENV REACT_APP_STORE_OWNER_ADDRESS_ADDRESS="" to your wallet address.
In js/packages/web/.env.production, set REACT_APP_STORE_OWNER_ADDRESS_ADDRESS to your wallet address.
Build your Docker image using:
Upload your image using gcloud cli. Refer to this guide.