Files
Miranda Limonczenko 1bdb8d849f docs: apply the quickstart template to the remaining quickstarts (#54502)
Closes DOCS-1616

## Problem

The remaining quickstarts don't follow the [quickstart
template](https://github.com/supabase/supabase/blob/docs/quickstart-template/apps/docs/style-guide/templates/quickstart.md)
either.

## Solution

- **Heading IDs:** each numbered step ends with the template's ID, such
as `[#create-the-client]`.
- **Heading wording:** eight headings now use the template's wording,
such as `Create the Supabase client`.
- **Style:** the prose follows the word list and elements rules.

**Not changed:** RedwoodJS, Spring Boot, and Refine. DOCS-1624 covers
them.

**Before and after:** numbered headings that use the template's wording.

| Page | Before | After |
| --- | --- | --- |
| iOS | 5/8 | 6/8 |
| Kotlin | 4/8 | 5/8 |
| Flask, Flutter, Unity | 5/7 | 6/7 |
| Expo | 6/7 | 7/7 |
| Reflex | 7/7 | 7/7 |
| Laravel | 3/7 | 3/7 |
| Rails | 3/6 | 3/6 |

**Possible errors, not changed:**

- The iOS page opens **Xcode > New Project > iOS > App**. Xcode's menu
might be **File > New > Project**.
- The Vue page says to drop a type import that `supabaseClient.ts`
doesn't have.

## Preview links

| Page | Preview |
| --- | --- |
| Flask |
[Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/flask)
|
| Reflex |
[Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/reflex)
|
| Expo React Native |
[Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/expo-react-native)
|
| Flutter |
[Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/flutter)
|
| iOS SwiftUI |
[Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/ios-swiftui)
|
| Kotlin |
[Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/kotlin)
|
| Unity |
[Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/unity)
|
| Laravel |
[Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/laravel)
|
| Ruby on Rails |
[Preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/ruby-on-rails)
|

## Review category (docs PRs only)

<!--
If this PR changes docs and you're on the Supabase team, select one
category.
PRs from forks are always reviewed as Low, so you can skip this section.
-->

- [ ] Critical: needs a review as soon as possible
- [ ] Urgent: the feature ships soon, or it's blocking something else
- [ ] Moderate: good to have soon, not urgent
- [ ] Low: get to it when you can

## Review instructions

1. Open the [Kotlin
preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/kotlin)
and click **Create the Supabase client** in the table of contents. The
URL ends in `#create-the-client`.
2. Open the [Laravel
preview](https://docs-git-docs-quickstart-rework-other-supabase.vercel.app/docs/guides/getting-started/quickstarts/laravel)
and click the **Run the database migrations** link in step 4. The page
scrolls to step 7.

## Checklist

Check all before review:

- [ ] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-12-03 14:40:59 -08:00

184 lines
5.9 KiB
Plaintext

---
title: 'Use Supabase with Unity'
subtitle: 'Learn how to create a Supabase project, add some sample data to your database, and query the data from a Unity app.'
breadcrumb: 'Framework Quickstarts'
---
<AiPrompt id="unity" />
<$Partial path="quickstart_db_setup.mdx" />
## 3. Create a Unity project [#create-an-app]
In Unity Hub, click **New project**. This guide uses Unity 6.3. It doesn't cover Web builds, because Unity Web doesn't support `System.Net.Http`, which the SDK uses.
## 4. Set up AI tooling (optional) [#set-up-ai-tooling]
<$Partial path="quickstart_ai_tooling.mdx" />
## 5. Install the Supabase client library [#install-the-client-library]
Unity can't install NuGet packages, so install [NuGetForUnity](https://github.com/GlitchEnzo/NuGetForUnity) first. You need Git installed for this step.
1. Open **Window > Package Management > Package Manager**.
2. Open the **+** menu and select **Install package from git URL**.
3. Paste this URL and click **Install**:
```text
https://github.com/GlitchEnzo/NuGetForUnity.git?path=/src/NuGetForUnity
```
4. Open **NuGet > Manage NuGet Packages** and install [`Supabase`](https://www.nuget.org/packages/Supabase).
## 6. Create the Supabase client [#create-the-client]
Add a `SupabaseManager.cs` script and attach it to an empty GameObject. It creates one client for the whole app. Replace the two placeholders with your project URL and publishable key. You can get both from the following helper, or from the project [**Connect** panel](/dashboard/project/_?showConnect=true&connectTab=frameworks&framework=dotnet&using=unity):
<Button variant="primary" asChild>
<a href="/dashboard/project/_?showConnect=true&connectTab=frameworks&framework=dotnet&using=unity">
Open Connect panel
</a>
</Button>
```csharp name=Assets/SupabaseManager.cs
using System.Threading.Tasks;
using Supabase;
using UnityEngine;
public class SupabaseManager : MonoBehaviour
{
public static SupabaseManager Instance { get; private set; }
public Client Supabase { get; private set; }
// Await this before you use the client.
public Task InitializationTask { get; private set; }
private const string Url = "YOUR_SUPABASE_URL";
private const string Key = "YOUR_SUPABASE_PUBLISHABLE_KEY";
private void Awake()
{
if (Instance != null)
{
Destroy(gameObject);
return;
}
Instance = this;
DontDestroyOnLoad(gameObject);
InitializationTask = InitializeAsync();
}
private async Task InitializeAsync()
{
Supabase = new Client(Url, Key);
await Supabase.InitializeAsync();
}
}
```
<$Partial path="api_settings.mdx" variables={{ "framework": "dotnet", "tab": "frameworks" }} />
<Admonition type="note">
Unity doesn't load `.env` files, so this guide puts the project URL and publishable key in the script. The publishable key is safe to ship in your app, because Row Level Security and database privileges control access to your data.
</Admonition>
## 7. Create a data model for instruments [#create-a-data-model-for-instruments]
Create an `Instrument.cs` file. The attributes map the class to the `instruments` table and its properties to the columns.
```csharp name=Assets/Instrument.cs
using Supabase.Postgrest.Attributes;
using Supabase.Postgrest.Models;
[Table("instruments")]
public class Instrument : BaseModel
{
[PrimaryKey("id")]
public long Id { get; set; }
[Column("name")]
public string Name { get; set; } = string.Empty;
}
```
## 8. Query data from the app [#query-data]
Create an `InstrumentList.cs` script and attach it to a GameObject in the same scene. It logs each instrument name.
```csharp name=Assets/InstrumentList.cs
using System;
using System.Threading.Tasks;
using UnityEngine;
public class InstrumentList : MonoBehaviour
{
// Unity doesn't await Start(), so this only starts the load.
private void Start()
{
_ = LoadInstrumentsAsync();
}
private async Task LoadInstrumentsAsync()
{
try
{
var manager = SupabaseManager.Instance;
await manager.InitializationTask;
var response = await manager.Supabase.From<Instrument>().Get();
foreach (var instrument in response.Models)
{
Debug.Log(instrument.Name);
}
}
catch (Exception e)
{
Debug.LogError($"Error loading instruments: {e.Message}");
}
}
}
```
## 9. Start the app [#start-the-app]
Run the scene and check its output:
1. Click **Play** in the editor.
2. Open **Window > General > Console**.
The **Console** shows `violin`, `viola`, and `cello`.
<$Partial path="quickstart_going_to_production.mdx" />
### IL2CPP code stripping
With a **Managed Stripping Level** higher than **Minimal**, IL2CPP removes code that the SDK needs. The query then returns empty names, and other calls fail. To keep the SDK and your models, add this `Assets/link.xml` file:
```xml name=Assets/link.xml
<linker>
<assembly fullname="Supabase" preserve="all" />
<assembly fullname="Supabase.Core" preserve="all" />
<assembly fullname="Supabase.Functions" preserve="all" />
<assembly fullname="Supabase.Gotrue" preserve="all" />
<assembly fullname="Supabase.Postgrest" preserve="all" />
<assembly fullname="Supabase.Realtime" preserve="all" />
<assembly fullname="Supabase.Storage" preserve="all" />
<assembly fullname="Assembly-CSharp">
<type fullname="Instrument" preserve="all" />
</assembly>
</linker>
```
Add a `type` line with the full name of each model class, including its namespace. If your scripts are in an assembly definition, use its name instead of `Assembly-CSharp`.
## Next steps
Build on this app with the following resources:
- Set up [Auth](/docs/guides/auth) for your app
- Explore the [C# reference](/docs/reference/csharp/introduction)
- [Insert more data](/docs/guides/database/import-data) into your database
- Upload and serve static files using [Storage](/docs/guides/storage)