How to Set Up a Django and React SaaS Boilerplate: A Step-by-Step Guide

I'll be using this boilerplate and adding to it so others can use, while building in public!


8 min read

Starting a Software as a Service (SaaS) project can be daunting, especially with the initial setup of the infrastructure. Luckily, with the right boilerplate, much of the groundwork is laid out for you. This guide will walk you through setting up a SaaS application using a specific Django backend and React frontend code, including integrating Stripe for payments, Postmark for emails, user management and authentication, Cloudinary for media file uploads, dynamically rendered landing page, blog creation through Django Admin, Google Analytics, Material UI, setting up a PostgreSQL database, and deploying to Let's dive in!

Backend Setup

Initial Setup

  1. Create a Project Folder: Start by navigating to your Desktop or preferred directory in your terminal and create a folder named saas-boilerplate. Then, create a subdirectory named backend and navigate into it.

     cd Desktop
     mkdir saas-boilerplate
     cd saas-boilerplate
     mkdir backend
     cd backend
  2. Clone the Boilerplate Repository: Clone the backend boilerplate repository into your backend directory.

     git clone .
  3. Set Up a Virtual Environment: Use virtualenv to create an isolated Python environment. Activate it and install the project's dependencies.

     pip install virtualenv
     python3.8 -m venv env
     source env/bin/activate
     pip install -r requirements.txt
  4. Environmental Variables: Create a .env file in your backend directory. Populate it with the necessary environmental variables provided below:

  5. Now you need to set up Stripe.

    1. If you do not have a stripe account register a free one here: If you do have a stripe account login here:

    2. Once account is set up or you're logged in, turn on `Test Mode` (Toggle button in top right corner of dashboard) it should bring you to:

    3. Go to

      1. Grab your `Publishable key` token and set the environmental variable `STRIPE_API_TEST_PK` in your `.env` file created above.

      2. Next grab your `Secret key` token and set the environmental variable `STRIPE_API_TEST_SK` in your `.env` file created from above.

      3. Next go to Stripe Products to add your products, i.e. subscription tiers

        1. Add as many tiers as you want i.e.

          1. Free w/ a description and price: $0

          2. Pro w/ a description and price: say $10

          3. Make sure both are Recurring and Monthly or however you would like to set up your subscriptions.

  6. Postgres Database Setup: Download and install PostgreSQL. You can use this download link. Once installed, create a database named postgres and ensure your reflects the correct database settings. For example: default="postgresql://postgres:postgres@localhost/postgres", if your database name is postgres.

  7. Apply migrations and create a superuser for Django admin access.

     python migrate
     python createsuperuser
  8. Running the Server: Start your Django server and log into the admin panel to verify that everything is set up correctly.

     python runserver

Integrating Stripe Products and Prices, Email, and Landing Page data

  1. Add Products and Prices: Navigate to the Django admin payments section to add Stripe products and their prices. Ensure each product in Django matches its counterpart in Stripe, including the recurring intervals and price IDs.

    1. You can find Stripe Product Id in stripe products and click on product and in the URL you will see an ID with prefix prod_xxxxxxxx and letters and numbers as the unique id.

    2. Do the same for all products

    3. Now go to Django Admin Product Price

      1. Add the price for each product from Stripe here: Django Admin Add Product Link

      2. Select Product that you added to Django Admin.

      3. Add the Price from what you entered on Stripe. Add the interval, i.e. Monthly

      4. Add the stripe price id

        1. Go to

          1. Select the Product and scroll down to Pricing and look under API ID and copy id with prefix and numbers/letters like price_xxxxxxxxx and paste into stripe price id on django admin. 5. Do for all products
      5. Now you can add descriptions of the tiers here: Django Admin Add Product Description Link

        1. Add as many description list items for each product
  2. Email Setup: Configure your development email settings by adding DEV_EMAIL_HOST_USER and DEV_EMAIL_HOST_PASSWORD to your .env file, using an app password generated from your Gmail account.

    1. Set DEV_EMAIL_HOST_USER to your gmail for DEV testing

    2. Set your DEV_EMAIL_HOST_PASSWORD to the password set up in your gmail account from above. You need to create an App Password in:

      1. Make sure 2-Step Authentication is enabled.

      2. Then go to and create a new app and a new password will be created.

      3. Now Emails will be sent through gmail smtp in DEV

  3. Next up is setting up the landing page data.

    1. Note here you can add whatever copy, images, icons, you would like through the Django admin

      1. Go to

        1. Add the hero section copy and image

        2. Add the features of your SaaS

          1. the Feature mui icon name: can be selected from i.e. find Add and get the name of the icon from the end of the import in the modal import AddIcon from '@mui/icons-material/Add'; i.e. Add

          2. You can add as many features as you like and Order them however you like by applying 1,2,3... to each feature. i.e. 1 will be first in line.

          3. Do the same for how it works, Secondary hero, and Social Media Links

  4. We will set up prod environmental variables later.

Frontend Setup

  1. Setting Up the Frontend: In a new terminal, navigate to your project root and set up the frontend directory by cloning the frontend boilerplate repository. Install dependencies with npm install.

     mkdir frontend
     cd frontend
     git clone .
     npm install
  2. Configure Environment Variables: Create a .env file in your frontend directory. Add your Stripe Publishable key and Google Analytics ID.

    1. Add the publishable key from Stripe to the environmental variable REACT_APP_STRIPE_API_TEST_PK with the value from STRIPE_API_TEST_PK in backend/.env

    2. Now add an environmental variable REACT_APP_GA_ID for Google Analytics

      1. Go to

        1. Add an analytics account

        2. Add an app

        3. Go to top search bar and search for MEASUREMENT ID in Data Streams and copy the ID that has prefix G-XXXXXXXX 4. Past that G-XXXXXXXX as value for environmental variable REACT_APP_GA_ID in frontend/.env

  3. Start the Frontend Server: Run npm start to launch your React app. Your SaaS landing page should now be visible at http://localhost:3000/.


  1. Prepare for Deployment: Ensure your backend and frontend folders are pushed to separate GitHub repositories.

  2. Deploying the Backend: Follow's documentation to deploy your Django app, adding the necessary environment variables for production, including Stripe keys, Cloudinary for media files, and email settings via Postmark.

    1. Follow tutorial here:

      1. The backend/render.yaml already exists in the saas boilerplate. You can change all the names to fit whatever you like, but our boilerplate named everything backend

        1. In the Render Dashboard, go to the Blueprints page and click New Blueprint Instance.

          1. Make sure to first create a repository to hold your backend/ folder on github.

          2. Now you can select the repository that contains your blueprint and click Connect.

          3. Give your blueprint project a name and click Apply.

        2. Now add the Production Environmental Variables by clicking the backend app and going to Environment

          1. Add you Stripe STRIPE_API_TEST_PK found in your local .env file or if you are ready to use live Stripe data use the Production PK found in stripe dashboard.

          2. Same with the STRIPE_API_TEST_SK

          3. STRIPE_LIVE_MODE=False

          4. BACKEND_URL will be the url that your backend render app is pointing to: something similar to this

          5. For your media files first set up Cloudinary account by going to the cloudinary website and create a free cloudinary account. After your account has been created, go to the dashboard page and copy the cloud name, api key and api secret.

            1. Add the cloud name to CLOUDINARY_CLOUD_NAME

            2. Add the api key to CLOUDINARY_API_KEY

            3. Add the api secret to CLOUDINARY_API_SECRET

          6. For your emails create a postmark account here Follow instructions here: to find your Server API Token and set it to POSTMARK_SERVER_TOKEN

            1. Set DEFAULT_FROM_EMAIL to your email with postmark.
          7. After you deploy the frontend app below, come back to setting FRONTEND_URL

          8. Finally run pythonmanage.pycreatesuperuser in the Render shell in the settings of the backend app so that you can create an admin account.

            1. To see your backend admin page, go to <YOUR_APP_URL>/admin to login.
  3. Deploying the Frontend: Deploy your React app on, setting environment variables for connecting to the backend API, Stripe, Cloudinary, and Google Analytics.

    1. Connect your github account here:

      1. Follow the instructions to deploy

        1. Once deployed go to settings for frontend app

          1. In Redirect/Rewrite rules add:

            1. /* as Source

            2. /index.html as Destination

            3. And Rewrite as Action

          2. Now go to Environment and add:

            1. REACT_APP_STRIPE_API_TEST_PK to same Stripe API Key that you set in backend

            2. Add REACT_APP_BACKEND_API_URL and use the backend url from above after backend was deployed

            3. Add your REACT_APP_MEDIA_URL to the Cloudinary url. Something like this The xxxxxxx should be found in your cloudinary dashboard that you used in backend set up.

            4. Now add REACT_APP_GA_ID from your .env REACT_APP_GA_ID in local file.

            5. Finally take the Frontend url from the react frontend app and set it in the backend app on's environmental variable FRONTEND_URL that you previously set up.

  4. FinalAdjustments: After deploying both frontend and backend, ensure all environment variables are correctly set and pointing to the right services. Test your live application to ensure everything works seamlessly.

Congratulations! You've successfully set up and deployed your SaaS boilerplate application. This setup provides a solid foundation for developing your SaaS product, with scalable options for payment processing, database management, and deployment strategies. Happy coding!

Coming soon!

P.S comment below on any issues!

Sign up for my newsletter to hear about my #buildinpublic journey!