Swiftpack.co - supabase-community/postgrest-swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by supabase-community.
supabase-community/postgrest-swift 0.0.4
Swift client for PostgREST
⭐️ 25
🕓 3 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/supabase-community/postgrest-swift.git", from: "0.0.4")

Postgrest Swift


Swift client for PostgREST. The goal of this library is to make an "ORM-like" restful interface.

Swift Package Manager

Add postgrest-swift as a dependency to your Package.swift file. For more information, please see the Swift Package Manager documentation.

.package(url: "https://github.com/supabase/postgrest-swift", .exact("0.0.4"))


You can also install the supabase-swift package to use the entire supabase library.


import Foundation
import PostgREST

let supabaseUrl = ""
let supabaseKey = ""

var database = PostgrestClient(
    url: "\(supabaseUrl)/rest/v1",
    headers: ["apikey": supabaseKey],
    schema: "public")

struct Todo: Codable, Hashable {
  let id: UUID
  var description: String
  var isComplete: Bool

  enum CodingKeys: String, CodingKey {
    case id
    case description
    case isComplete = "is_complete"

struct NewTodo: Codable, Hashable {
  var description: String
  var isComplete: Bool = false

  enum CodingKeys: String, CodingKey {
    case description
    case isComplete = "is_complete"

// Get todos
var todos = try await client
    .decoded(to: [Todo].self)

// Insert a todo
let insertedTodo = try await client.from("todo")
    .insert(values: NewTodo(description: "Implement integration tests for postgrest-swift"))
    .decoded(to: [Todo].self)[0]

// Insert multiple todos
let insertedTodos = try await client.from("todo")
    .insert(values: [
        NewTodo(description: "Make supabase swift libraries production ready"),
        NewTodo(description: "Drink some coffee"),
    .decoded(to: [Todo].self)


  • Fork the repo on GitHub
  • Clone the project to your own machine
  • Commit changes to your own branch
  • Push your work back up to your fork
  • Submit a Pull request so that we can review your changes and merge


This repo is liscenced under MIT.


Stars: 25
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

3 weeks ago

What's Changed

  • Add support for passing a custom Fetch function when initializing the client.
  • Add X-Client-Info header to all requests
  • Add auth(token:) method to PostgrestClient, this allows to to change to JWT from outside by the library user
  • Add the CountOption parameter for specifying the count algorithm to use when counting tables on several methods.
  • General improvements to the code.

Full Changelog: https://github.com/supabase-community/postgrest-swift/compare/0.0.3...0.0.4

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics