Warning
You are viewing the technical documentation for the Sharetribe Developer Platform. If you are looking for our no-code documentation, see our help center.

Last updated

Deploy to production

This article describes what to take into account when you deploy the Sharetribe Web Template to production.

Table of Contents

What is a production environment?

A production environment hosts and executes the code that runs your live marketplace and serves it to the public internet. The version of your marketplace intended for real-life use with real money runs in the production environment. Typically, alongside your production environment, you will also host another version of your client environment: a test environment.

Having several environments is a common practice in software development. The test environment is most often a clone of the production environment intended for testing new features before being deployed to production. Once a development team deems a feature production-ready, i.e. fit for a live audience, they can deploy it to production. A workflow like this helps prevent bugs and unfinished code from being released to your users.

Sharetribe offers three different environment types – Live, Test, and Dev. You should connect your client application with the corresponding marketplace environment, i.e. your client environment intended for development should use environment variables that point to your dev environment in Sharetribe.

More specifically, the workflow recommended with Sharetribe is that you have three deployments of your client application:

  • production deployment, connected to your Live environment and running real transactions
  • test deployment, connected to your Test environment and intended for previewing no-code changes
  • dev deployment, connected to your Dev environment and intended for testing and previewing code-level changes.

We recommend that you keep your production and test deployments identical, so that operators can preview their no-code changes reliably. Read more: Sharetribe environments.

Where to host your application?

There are many hosting providers to choose from when considering where to host your marketplace. Our official recommendation is to host your marketplace on Heroku or Render for a hassle-free installation. However, you are free to host your marketplace elsewhere. The Sharetribe Web Template should be compatible with any hosting provider as long as they allow you to run a Node.js/Express server. Many essential functions in the template rely on a small Node.js/Express server (such as server-side rendering, SSO and transitioning privileged transactions). Serverless service providers such as Netlify and Vercel are unsuitable for hosting the template as they don't allow you to host a server.

When choosing a hosting provider, you should not only consider the cheapest option. Scalability, tools, service-level agreements and available computing resources are examples of factors that should weigh in when choosing a hosting provider. It is also possible that hosting providers' prices and services may change over time, e.g. Heroku discontinued its popular free tier in October 2022.

As of the time of writing, Render and Fly.io continue to provide a free tier, which you can use, e.g. to host a test application. You will have to move to a paid plan for a production-level deployment to ensure consistent uptime and computing resources for your marketplace. Other alternatives you can look into include AWS, Google Cloud, Digital Ocean and Microsoft Azure. If your deployment solution requires using containers, you can refer to our guide on running the template in a Docker container.

Deploying to production

Deploying your marketplace to production is a three-step process:

  1. Set environment variables
  2. Build the app
  3. Run the node server

Environment variables

For a full list of possible environment variables, see the Environment configuration variables reference for more information. To deploy your marketplace, you need to add at least the following variables:

  • NODE_ENV

Use the value 'production'.

  • PORT

You must set a port if the production environment does not set one by default. Heroku and Render define a port automatically.

  • REACT_APP_SHARETRIBE_SDK_CLIENT_ID

Your client ID. You can find it in Sharetribe Console.

  • SHARETRIBE_SDK_CLIENT_SECRET

Your client secret. You can find it in Sharetribe Console.

  • REACT_APP_STRIPE_PUBLISHABLE_KEY

Stripe publishable API key for generating tokens with Stripe API. You find it on the Stripe API keys page. You will also need to add the secret key in Sharetribe Console.

  • REACT_APP_MARKETPLACE_ROOT_URL

This is the root URL of the marketplace. For example: https://the-name-of-your-app.herokuapp.com. The template uses the root URL for social media sharing and SEO optimization.

  • REACT_APP_MARKETPLACE_NAME

The Marketplace name in self-hosted marketplaces is set through environment variables. If not set, this will default to 'Biketribe', or whatever hard-coded value you have set in src/config/configDefault.js.

  • REACT_APP_MAPBOX_ACCESS_TOKEN

The Mapbox access token is specified via Console, under Integrations > Map. The template fetches this access token via assets. This environment variable is used as a fallback, and therefore is not mandatory. See the How to set up Mapbox for Sharetribe Web Template guide for more information.

Building the app

Running the following command builds the app for production to the build folder. It correctly bundles React in production mode and optimizes the build for the best performance.

yarn build

After this, your app is ready to be deployed.

Start the server

To start the server, you need to run:

yarn start