Skip to content

Latest commit

 

History

History
197 lines (122 loc) · 8.8 KB

DEVELOPERS.md

File metadata and controls

197 lines (122 loc) · 8.8 KB

Developing Supabase

  1. Getting started
  2. Local development
  3. Create a pull request

Getting started

Thank you for expressing your interest in Supabase and your willingness to contribute!

To ensure a positive and inclusive environment, we kindly request you to read our code of conduct. Additionally, we encourage you to explore the existing issues to see how you can make a meaningful impact. This document will guide you through the process of setting up your development environment, enabling you to successfully build and test Supabase.

Install dependencies

You will need to install and configure the following dependencies on your machine to build Supabase:

Local development

We are in the process of migrating this repository to monorepo, using Turborepo.

Eventually, all the apps will be run using Turborepo, which will significantly improve the developer workflow.

Fork the repository

To contribute code to Supabase, you must fork the Supabase Repository.

Clone the repo

  1. Clone your GitHub forked repository:

    git clone https://github.com/<github_username>/supabase.git
  2. Go to the Supabase directory:

    cd supabase

Running turborepo

Supabase uses Turborepo to manage and run this monorepo.

  1. Install the dependencies in the root of the repo.

    npm install # install dependencies
  2. After that you can run the apps simultaneously with the following.

    npm run dev # start all the applications

Then visit, and edit, any of the following sites:

Site Directory Scope name Description Local development server
supabase.com /apps/www www The main website http://localhost:3000
supabase.com/dashboard /studio studio Studio dashboard http://localhost:8082
supabase.com/docs /apps/docs docs Guides and Reference (Next.js based) http://localhost:3001/docs

Running sites individually

You can run any of the sites individually by using the scope name. For example:

npm run dev:www

Shared components

The monorepo has a set of shared components under /packages:

  • /packages/common: Common React code, shared between all sites.
  • /packages/config: All shared config
  • /packages/spec: Generates documentation using spec files.
  • /packages/tsconfig: Shared Typescript settings

Installing packages

Installing a package with NPM workspaces requires you to add the -w flag to tell NPM which workspace you want to install into. Do not install dependencies in their local folder, install them from the route using the -w flag.

The format is: npm install <package name> -w=<workspace to install in>.

For example:

  • npm install react -w common: installs into ./packages/common
  • npm install react -w www: installs into ./apps/www
  • npm install react -w studio: installs into ./studio

You do not need to install devDependencies in each workspace. These can all be installed in the root package.

New Supabase docs

Following the changes to the Supabase docs the following is needed to run the new docs locally:

  • Inside of apps/docs create a .env.local file with the following: NEXT_PUBLIC_NEW_DOCS=true

Now when you run a local development docs server you will see the new docs site.


Running Docker

To test your changes, you need to run Supabase using Docker. Docker lets you use features of your locally modified Supabase version.

Prerequsites

First, make sure you have the Docker application installed on your device. You can download and install it from here.

Getting Started

  1. Navigate to the docker directory in your forked repo

    cd docker
  2. Copy the example env file

    cp .env.example .env
  3. Run docker

    docker-compose up

This command initializes the containers specified in the docker-compose.yml file. It might take a few moments to complete, depending on your computer and internet connection.

Once the docker-compose up process completes, you should have your local version of Supabase up and running within Docker containers. You can access and test the features you've modified or added.

Remember to keep the Docker application open as long as you're working with your local Supabase instance.

Create a pull request

After making your changes, open a pull request. Once you submit your pull request, the Supabase team will review it with you.

Once your PR has been merged, you will be proudly listed as a contributor in the contributor chart.


Common tasks

Add a redirect

Create a new entry in the redirects.js file in our main site.


Federated docs

We support "federating" docs, meaning doc content can come directly from external repos other than supabase/supabase.

  • It's great for things like client libs who have their own set of docs that we don't want to duplicate on the official Supabase docs (eg. supabase/vecs).
  • No duplication or manual steps required - fetches and generates automatically as part of the docs build pipeline
  • It's flexible - you can "embed" external docs nearly anywhere at any level in Supabase docs, but they will feel native
  • If you are maintaining a repo containing docs that you think could also live in Supabase docs, feel free to create an issue and we can work together to integrate

Federated docs work using Next.js's build pipeline. We use getStaticProps() to fetch remote documentation (ie. markdown) at build time which is processed and passed to the respective page within the docs.

See the Vecs Python source code to see how we do this for supabase/vecs. Use this as a starting point for federating other docs.

Some things to consider:

  • Links will often need to be transformed. For example if you are bringing in external markdown content, they may contain relative links that may not translate 1-to-1 after rendering in the Supabase docs. Use the Link Transform rehype plugin to transform links.
  • External markdown may contain syntax extensions that Supabase docs don't understand by default (eg. mkdocs-material extensions). We've built a few remark plugins to support these extensions (eg. MkDocs Admonition). If there is a markdown extension that you need that isn't built yet, feel free to open an issue and we can work together to create it.

Community channels

If you are stuck somewhere or have any questions, join our Discord Community Server or the Github Discussions. We are here to help!

Contributors

contributors