Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Serverpod documentation

This is the documentation for Serverpod an open-source backend for Flutter written in Dart. The documentation is created using Docusaurus.

Rules:

- When writing documentation, always follow the instructions in the STYLE_GUIDE.md.
- Do NOT attempt to run `npm run build` or similar, instead ask the user for verification.
- When linking to other pages in the documentation use this format: `[Working with endpoints](./concepts/working-with-endpoints)`. This will ensure that the links work within the same version of the docs.
3 changes: 2 additions & 1 deletion docs/01-get-started/01-creating-endpoints.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
sidebar_label: 1️⃣ Creating endpoint methods
sidebar_label: Creating endpoint methods
sidebar_class_name: sidebar-icon-get-started-step-1
---

# Creating endpoint methods
Expand Down
3 changes: 2 additions & 1 deletion docs/01-get-started/02-models-and-data.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
sidebar_label: 2️⃣ Models and data
sidebar_label: Models and data
sidebar_class_name: sidebar-icon-get-started-step-2
---

# Models and data
Expand Down
3 changes: 2 additions & 1 deletion docs/01-get-started/03-working-with-the-database.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
sidebar_label: 3️⃣ Working with the database
sidebar_label: Working with the database
sidebar_class_name: sidebar-icon-get-started-step-3
---

# Working with the database
Expand Down
3 changes: 2 additions & 1 deletion docs/01-get-started/04-deployment.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
sidebar_label: 4️⃣ Deploying Serverpod
sidebar_label: Deploying Serverpod
sidebar_class_name: sidebar-icon-get-started-step-4
---

# Deploying Serverpod
Expand Down
5 changes: 3 additions & 2 deletions docs/01-get-started/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"label": "🚀 Getting started",
"collapsed": false
"label": "Getting started",
"collapsed": false,
"className": "sidebar-icon-getting-started"
}
3 changes: 2 additions & 1 deletion docs/02-overview.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
sidebar_label: 🧭 Overview
sidebar_label: Overview
sidebar_class_name: sidebar-icon-overview
---

# Overview
Expand Down
3 changes: 2 additions & 1 deletion docs/04-support.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
sidebar_label: 💬 Support & community
sidebar_label: Support & community
sidebar_class_name: sidebar-icon-support
---

# Support & community
Expand Down
2 changes: 1 addition & 1 deletion docs/05-tutorials/01-academy.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_label: 🏫 Serverpod Academy
sidebar_label: Serverpod Academy
---

# Serverpod Academy
Expand Down
2 changes: 1 addition & 1 deletion docs/05-tutorials/02-tutorials/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"label": "🎥 Tutorials",
"label": "Tutorials",
"collapsed": true
}
5 changes: 3 additions & 2 deletions docs/05-tutorials/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"label": "🎓 Learn Serverpod",
"collapsed": false
"label": "Learn Serverpod",
"collapsed": false,
"className": "sidebar-icon-learn"
}
5 changes: 3 additions & 2 deletions docs/06-concepts/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"label": "📚 Reference",
"collapsed": true
"label": "Reference",
"collapsed": true,
"className": "sidebar-icon-reference"
}
3 changes: 2 additions & 1 deletion docs/07-deployments/_category_.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"label": "🚢 Deploying Serverpod"
"label": "Deploying Serverpod",
"className": "sidebar-icon-deploying"
}
3 changes: 2 additions & 1 deletion docs/08-upgrading/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"label": "🔄 Upgrading"
"label": "Upgrading",
"className": "sidebar-icon-upgrading"
}

5 changes: 3 additions & 2 deletions docs/09-tools/_category_.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"label": "🧰 Tools",
"collapsed": true
"label": "Tools",
"collapsed": true,
"className": "sidebar-icon-tools"
}

3 changes: 2 additions & 1 deletion docs/10-contribute.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
sidebar_label: 🛣️ Roadmap & contributions
sidebar_label: Roadmap & contributions
sidebar_class_name: sidebar-icon-roadmap
---

# Roadmap & contributions
Expand Down
145 changes: 7 additions & 138 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
---
sidebar_position: -1
sidebar_label: 📦 Installation
sidebar_label: Introduction
sidebar_class_name: sidebar-introduction-icon
---

# Installation
# Introduction

Serverpod is an open-source, scalable backend framework built specifically for Flutter developers. It allows you to use Dart for your entire stack, simplifying development and reducing context-switching.

<div style={{ position : 'relative', paddingBottom : '56.25%', height : '0' }}><iframe style={{ position : 'absolute', top : '0', left : '0', width : '100%', height : '100%' }} width="560" height="315" src="https://www.youtube-nocookie.com/embed/teOnBD5d8b8" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>

## 🚀 Build your Flutter backend with Dart
## Build your Flutter backend with Dart

Maintain a single-language codebase with Serverpod. Write backend endpoints in Dart and call them directly from your Flutter app without writing boilerplate code. Our state-of-the-art code generation takes care of all the steps in between. Under the hood, Serverpod uses proven web standards and best practices.

Expand All @@ -28,23 +29,23 @@ final greeting = await client.example.greet('World');
print(greeting); // Hello World
```

### 🌱 Scalable and progressive
### Scalable and progressive

Serverpod is designed to grow with your needs. Start with a minimal setup and gradually introduce complexity as your application evolves:

- **Modular:** Easily add new features or services when necessary.
- **Scalable:** Grows from hobby project to millions of active users without changing a line of code.
- **Flexible:** Adaptable to various project requirements. Plug in Redis or stay purely Postgres – your choice.

### 🌟 Benefits of Serverpod
### Benefits of Serverpod

Startups and agencies use Serverpod to streamline development processes, accelerate iteration cycles, and empower single developers to build full features:

- **Reduced complexity:** Minimize friction by using a single language. Modules make sharing app and server code, database schemas, and APIs between your projects easy.
- **Open and free:** Avoid vendor lock-in. Deploy servers anywhere you can run Dart.
- **Stable and reliable:** Integrated logging, error monitoring, and automated database management. Battle-tested in real-world applications and secured by over 5,000 automated tests.

### 🛠️ Features our developers love
### Features our developers love

Serverpod comes packed with powerful features - batteries included.

Expand All @@ -53,135 +54,3 @@ Serverpod comes packed with powerful features - batteries included.
- **Straightforward authentication:** Quickly integrate popular authentication providers like sign-in with Google, Apple, or Firebase.
- **All essentials covered:** Built-in support for common tasks like handling file uploads, scheduling tasks, and caching data.
- **Cloud ready:** Deploy to Serverpod Cloud with zero configuration (coming soon - **[join the waiting list](https://forms.gle/JgFCqW3NY6WdDfct5)**), use pre-configured Docker containers, or use Terraform scripts for deploying to AWS or Google Cloud.

## Installation

### Prerequisites

Serverpod is tested on Mac, Windows, and Linux. Before you can install Serverpod, you need to have **[Flutter](https://flutter.dev/docs/get-started/install)** installed.

:::info
Check your Flutter installation by running the following command in your terminal:

```bash
$ flutter doctor
```

:::

To make use of Serverpod's database connectivity, you need to have access to a PostgreSQL database. We recommend using Docker to run PostgreSQL locally. You can find instructions for installing Docker on the official **[Docker website](https://docs.docker.com/get-docker/)**. Each Serverpod project comes with its own `docker-compose.yaml`, so there is no need to install any custom containers. We will guide you through the process in the Getting Started section.

:::info
Check your Docker installation by running the following command in your terminal:

```bash
$ docker info
```

If you are using Docker Desktop and you get an error, make sure that Docker is running. You can check this by looking for the Docker icon in your system tray or taskbar. If it's not running, start Docker Desktop and try again.
:::

### Install Serverpod

Serverpod is installed using the Dart package manager. To install Serverpod, run the following command in your terminal:

```bash
$ dart pub global activate serverpod_cli
```

This command will install the Serverpod command-line interface (CLI) globally on your machine. You can verify the installation by running:

```bash
$ serverpod
```

If everything is correctly configured, the help for the `serverpod` command is now displayed.

### Install the VS Code extension (recommended)

The Serverpod VS Code extension makes it easy to work with your Serverpod projects. It provides real-time diagnostics and syntax highlighting for model files in your project.
![Serverpod extension](/img/syntax-highlighting.png)

You can **[install the extension](https://marketplace.visualstudio.com/items?itemName=serverpod.serverpod)** from the VS Code Marketplace or search for _Serverpod_ from inside VS Code.

### Install Serverpod Insights (recommended)

**[Serverpod Insights](./09-tools/01-insights.md)** is a companion app bundled with Serverpod. It allows you to access your server's logs and health metrics. Insights is available for Mac and Windows, but we will be adding support for Linux in the future.
![Serverpod Insights](/img/serverpod-insights.webp)

## Creating a new project

To create a new Serverpod project, use the `serverpod create` command. It will set up a new project with a server, a client, and a Flutter app.
The project will be created in a new directory with the name you specify. For example, to create a new project called `my_project`, run the following command:

```bash
$ serverpod create my_project
```

:::tip
The name of the project must be a valid Dart package name. It should start with a lowercase letter and can only contain lowercase letters, numbers, and underscores. For example, `my_project` is a valid name, but `MyCounter` is not.
:::

After running the command, the following structure will be created:

```text
my_project/
├── my_project_server/ # Contains your server-side code.
├── my_project_client/ # Code needed for the app to communicate with the server.
└── my_project_flutter/ # Flutter app, pre-configured to connect to your local server.
```

The root-level `pubspec.yaml` file includes support for [Dart pub workspaces](https://dart.dev/tools/pub/workspaces) by default, which allows fetching dependencies at once by calling `dart pub get` from the project root.

:::info
During project creation, dependencies are automatically fetched.
:::

To run your new project you must first start the database from the Docker file that is included with the project. Do this by running the `docker compose up` command in the server directory:

```bash
$ cd my_project/my_project_server
$ docker compose up
```

This will start the PostgreSQL database. You can stop the database server by pressing `Ctrl+C` in the terminal. If you want to run the servers in the background, you can use the `-d` flag:

```bash
$ docker compose up -d
```

This will start the database server in detached mode, meaning it will run in the background and you can safely close the terminal window without stopping it. Stop the database container by running the following command from the server directory:

```bash
$ docker compose down
```

:::tip
If you are using Docker Desktop, you can see and manage all your installed Docker containers from there. It's easy to start and stop containers, and to remove the ones you are no longer using.
:::

Now that the database is up and running we can start the Serverpod server. Because we are running the project for the first time, we need to create the database tables used by Serverpod. This is done through a [database migration](./06-concepts/06-database/11-migrations.md). An initial migration is already created for us, so all we need to do is pass the `--apply-migrations` flag when starting the server:

```bash
$ cd my_project/my_project_server
$ dart run bin/main.dart --apply-migrations
```

This will start the server and set up the initial database tables. You can now access the server at `http://localhost:8080` and the web server is available at `http://localhost:8082`. It should look like this:

![Serverpod web](/img/getting-started/serverpod-web.png)

Now let's run our Flutter app. You can do this by running `flutter run -d chrome` in the flutter directory:

```bash
$ cd my_project/my_project_flutter
$ flutter run -d chrome
```

This will start the Flutter app in your browser. It should look like this:

![Example Flutter App](/img/getting-started/flutter-example-web.png)

## Next steps

The quickest way to learn Serverpod is to follow our 30-minute **[Getting Started](01-get-started/01-creating-endpoints.md)** guide. This will give you an excellent overview of creating endpoints and models and working with the database. You will create a fun app that magically creates recipes from the ingredients you have in your fridge.
Loading
Loading