CMS Orbit now speaks PHP, Swift and Kotlin
Laravel and Symfony websites and native iOS and Android apps get official SDKs too. All four are typed, open source and read the same content.
4 min read
On this page
CMS Orbit has always been headless. Content leaves it as JSON, over REST or GraphQL, and any website or app can read it. Until now, though, only JavaScript developers had an official SDK. Today there are four: JavaScript and TypeScript, PHP, Swift and Kotlin.
All four are typed, open source under the MIT licence and read the same delivery API. Pick the one for the language you already use, and read your first page in a few lines.
Why more than JavaScript
Plenty of websites aren't built with Next.js. Agencies run client websites on Laravel and Symfony. Organisations keep a PHP website they trust and don't want to rewrite. And more and more content belongs in native apps as well as on the web: opening times, offers, help pages and news in an iOS or Android app.
Each of those teams could already call the REST API. But an SDK takes care of the work around the call: keys, regions and languages, retries, timeouts, typed answers and clear errors. That work is now done for you in four languages, the same way in each.
The four SDKs
JavaScript and TypeScript
@bifrost-orbit-cms/sdk on npm is the SDK this website is built with. It has a typed client, a React renderer for your own components, Next.js helpers for preview, cache refresh and sitemaps, SEO output and a mock client for tests.
Quick start: Run npm install @bifrost-orbit-cms/sdk, create a client with createCmsClient({ baseUrl, apiKey }) and call await cms.getPage('/products/hiking-boots').
PHP
bifrost-orbit/cms-sdk works in Laravel, Symfony and plain PHP 8.1 or later. It brings its own transport, or uses any PSR-18 client you already have. It builds head tags, JSON-LD and sitemap XML, checks preview tokens and publish webhooks, and draws a page's components with your own templates.
Quick start: Run composer require bifrost-orbit/cms-sdk, create a client with new Client(apiKey: getenv('CMS_PUBLIC_KEY')) and call $cms->getPage('/products/hiking-boots').
Swift
The CMSOrbit package is for apps on iOS 15 or later and macOS 12 or later, and for server-side Swift. It uses async/await on URLSession, has no dependencies and answers with Codable models, or decodes fields into your own types. The guide includes SwiftUI examples.
Quick start: Add https://github.com/bifrost-orbit/cms-sdk-swift with Swift Package Manager, create a client with try CMSOrbitClient(apiKey: "cms_pk_...") and call try await cms.page("/products/hiking-boots").
Kotlin
com.bifrostorbit:cms-sdk runs in Android apps and on JVM servers, such as Ktor or Spring Boot. It has suspend functions for coroutines and futures for Java, and it's built on OkHttp and kotlinx.serialization. The guide includes a Jetpack Compose example.
Quick start: Add implementation("com.bifrostorbit:cms-sdk:0.1.0") to your Gradle build, create a client with CmsOrbitClient("cms_pk_...") and call cms.getPage("/products/hiking-boots") from a coroutine.
Types from your schema, in every language
The type generator reads your space's content types and components and writes a type for each one. npx cms-orbit generate writes TypeScript. Add --lang php, --lang swift or --lang kotlin for the other SDKs. It runs with npx, so it needs Node.js where you run it, not in your app.
Run it in CI. When someone renames a field or removes a component, the build that depends on it fails, instead of the website or app.
Safe keys in apps
Anything inside an app can be read by whoever installs it. So apps use a public key, which starts with cms_pk_ and reads published content only. The SDKs refuse secret keys in browser code and in iOS and Android apps. Previews of drafts need a secret key, so they run on a server, where the key stays private.
The same in every SDK
The four SDKs share more than a name. Learn one and the others feel familiar:
- One delivery API: The same calls for pages, redirects, menus, site-wide content, lists, products and sitemaps, with the same answers and errors.
- Regions and languages: Ask for a region and a language, with the same fallbacks everywhere. Read more about regions and languages.
- Preview: Drafts from Staging for the live preview, on the server.
- Campaigns: Banners and popups arrive with their audience and timing, ready to show.
- Retries and timeouts: Network and server errors are retried, and every call has a time limit.
Open source, under the MIT licence
All four SDKs are free with every CMS Orbit plan and open source under the MIT licence. The PHP SDK, Swift SDK and Kotlin SDK are on GitHub, and the JavaScript SDK is on npm as @bifrost-orbit-cms/sdk. Read the code, and tell us what you'd like next.
Using another language? The SDKs are a convenience, not a requirement. Python, Ruby, Go, .NET and anything else can read the same content over the delivery API or GraphQL.
Get started
Compare the four on the SDKs page, then follow the guide for your language: JavaScript, PHP, Swift or Kotlin. Start a free trial, create a public key and read your first page today. If you'd like to talk it through first, get in touch and a person on our team will answer.