Getting Started

Lets start building your SaaS project with Open Micro SaaS

Welcome to the beginning of your journey with Open Micro SaaS, the ultimate Next.js-based toolkit designed to streamline the development of your SaaS project.

This guide will walk you through the setup process, from cloning the repository to running your first set of integration tests. Let's get your project off the ground.

Installation

Step 1: Create Your Project from the Template

Instead of directly cloning the Open Micro SaaS repository, you'll start by creating a new repository based on our GitHub template (instructions bellow).

The easiest way to use this template, is running:

npx create-next-app -e https://github.com/product-makers-hub/open-micro-saas

This script will create a new Next.js project using the Open Micro SaaS template. You are good to go to step 2!

If you prefer to do it manually, follow these steps:

  1. Navigate to the Open Micro SaaS Template Repository: Go to the Open Micro SaaS public template on GitHub (opens in a new tab).
  2. Use the Template: Click the "Use this template" button near the top right of the repository page.
  3. Set Up Your Repository: Choose a name for your new repository and decide if it will be public or private. Then, click "Create repository from template" to generate your new project repository.

Step 2: Install Dependencies

Once you've created your project repository from the Open Micro SaaS template, the next step is to set up your project environment by installing the necessary dependencies. This will ensure that all the tools and libraries needed for your SaaS application are correctly installed and ready to use.

  1. Navigate to Your Project Directory: Change into your project's directory which you've just cloned to your local machine:

    cd your-repository-name
  2. Install Dependencies: Run the following command in your terminal to install the project dependencies:

    npm ci

Using npm ci instead of npm install not only ensures that you're working with the correct versions of dependencies but also typically results in faster installation times. It's particularly beneficial for continuous integration/continuous deployment (CI/CD) environments and when setting up a new development environment to match the project's specified dependencies precisely.

Step 3: Configure Environment Variables

Set up your environment variables by copying the .env.example file to a new .env file. This file will store crucial configurations for your project.

cp .env.example .env  # Use 'copy' command on Windows

Step 4: Set Up Next Auth Secret

Secure your application by generating a Next auth secret. This key adds an extra layer of security to your user authentication process.

openssl rand -base64 32

For detailed instructions and alternatives, refer to Next Auth's documentation (opens in a new tab).

Step 5: Database Configuration

Input your database credentials in the .env file. The default docker-compose.yml is set with the following placeholders; adjust according to your preferences:

POSTGRES_HOST=127.0.0.1
POSTGRES_PORT=6500
POSTGRES_USER=your-user-that-you-want
POSTGRES_PASSWORD=your-password-that-you-want
POSTGRES_DB=your-db-that-you-want
DATABASE_URL="postgresql://your-user-that-you-want:your-password-that-you-want@localhost:6500/your-db-that-you-want?schema=public"

Ensure consistency in the DATABASE_URL and individual Postgres environment variables.

Step 6: Initialize the Database

Use Docker to set up your PostgreSQL database. If you haven't installed Docker, find the installation guide here (opens in a new tab).

npm run db:start

As alternative, you can use the following options to set up your database without Docker:

  1. To use a remote database.
  2. To use a local PostgreSQL installation (opens in a new tab) in your machine.

Make sure to update the DATABASE_URL in your .env file accordingly if you choose one of these options.

Step 7: Run the migrations

Run the migrations to set up the database schema:

npm run db:migrate:dev

This command will create the necessary tables and relationships in your database.

Step 8: Launch the Development Server

Everything's set! Start the development server and begin building:

npm run dev

Your server will run on http://localhost:3000.

Creating an admin user

To create an admin user, you can use the following command:

npm run script:create:admin

This will read your ADMIN_EMAIL env variable and create an admin user with the provided email address.

Notice that you need to have your development database running.

Explore Real-World Use Cases

Now that you're familiar with the basics of setting up Open Micro SaaS, it's time to dive deeper into how this powerful Next.js SaaS boilerplate can be utilized to bring your innovative ideas to life. Our Use Cases section is designed to inspire and guide you through the diverse possibilities Open Micro SaaS offers.

What You'll Find in the Use Cases Section

  • Inspiring Projects: Discover a variety of projects built with Open Micro SaaS, showcasing how developers and businesses alike have leveraged the boilerplate to create impactful solutions.

  • Step-by-Step Guides: Each use case is accompanied by detailed guides that walk you through the implementation process, from concept to deployment, highlighting how specific features of Open Micro SaaS were utilized.

  • Ideas to Implementation: Whether you're looking to build a B2B platform, an e-commerce site, or a subscription-based service, our use cases will provide the insights and motivation needed to turn your idea into a fully functional SaaS application.

  • Community Contributions: Explore innovative applications developed by the Open Micro SaaS community. Learn from their experiences and see how collaboration and feedback have enriched the boilerplate's ecosystem.

Explore Use Cases →

Let these real-world applications inspire your next SaaS project. See how Open Micro SaaS can serve as the foundation for your success, and don't hesitate to share your journey with us. Together, we're building the future of SaaS, one project at a time.

What's Next?

Now that you've set up your project, you're ready to start building your micro SaaS application.

Here are a few next steps to consider:

  • Review the features: Take a look at the features that come out of the box with Open Micro SaaS. This includes user authentication, billing, and more. Familiarize yourself with these features to understand how they can be customized and extended to fit your specific needs.
  • Read the tutorials: Explore the tutorials to learn how to customize and extend Open Micro SaaS. These tutorials cover a range of topics, from adding new features to writing tests and deploying your application.
  • Explore the Project Structure: Familiarize yourself with the project structure and the various components that make up Open Micro SaaS. This will help you understand how to customize and extend the toolkit to fit your specific needs.
  • Add New Features: Start building out the features and functionality you need for your SaaS application. Open Micro SaaS provides a solid foundation, including user authentication, billing, and more, so you can focus on building the unique aspects of your project.

Congratulations! You've successfully set up Open Micro SaaS.

This guide is just the beginning—explore our extensive documentation for more on customizing and enhancing your micro SaaS project.

Encounter any roadblocks? Our community is here to help. Join the discussion (opens in a new tab) and contribute to making Open Micro SaaS even better.

Happy building!