Back to blog

Introducing Enum SDK support: enhanced DX across SDKs

A new feature that will reduce friction and improve your experience.

We are excited to announce a significant enhancement to the development experience across all Appwrite client and server-side SDKs, Enums SDK Support.

This enhancement is designed to streamline the development process, improve code quality, and facilitate seamless integration with Appwrite's backend services.

What are Enums?

Enums, or enumerations, are a powerful programming construct that enables developers to define a set of named constants. These constants make code more readable and less error-prone by providing meaningful names for values rather than using numbers or strings directly. Enums are widely used for representing a set of possible values for a variable, making code easier to understand, maintain, and debug.

Introducing Enum SDK support in Appwrite

Currently, when you want to use an endpoint with a predefined set of allowed values, you must look up the exact value in the documentation. This can be time-consuming and error-prone.

This new feature, however, ensures you can use more readable and self-documenting code instead of having to remember and type out raw values.

Bringing along benefits such as massively reducing friction when using routes that have predefined parameters. One of the most common examples of SDK Enums is OAuth providers. To log in with Apple, you must pass the apple string as the provider. With enums, you'll be able to pass OAuthProvider.Apple instead.

Web
import { Client, Account, OAuthProvider } from "appwrite";

const client = new Client()
    .setEndpoint('https://cloud.appwrite.io/v1')
    .setProject('<PROJECT_ID>');

const account = new Account(client);

account.createOAuth2Session(OAuthProvider.Apple, '[LINK_ON_SUCCESS]', '[LINK_ON_FAILURE]', true);

This new feature will improve the experience of building with Appwrite and lower the barrier for new developers to start. As always, we aim to make life easier, not harder, and we look forward to your feedback.

Resources

Visit our documentation to learn more about Enums SDK support, join us on Discord to be part of the discussion, view our blog and YouTube channel, or visit our GitHub repository to see our source code.

Enums will be available as part of the Appwrite 1.5 release on GitHub and Cloud in March 2024.

Subscribe to our newsletter

Sign up to our company blog and get the latest insights from Appwrite. Learn more about engineering, product design, building community, and tips & tricks for using Appwrite.