Skip to content
Blog / Introducing Type generation: Automate your type definitions with Appwrite
4 min

Introducing Type generation: Automate your type definitions with Appwrite

Automatically generate types from your collections with support for multiple languages.

Introducing Type generation: Automate your type definitions with Appwrite

We're excited to announce Appwrite’s newest CLI feature, Type generation. Designed specifically to enhance your developer experience. Type generation automates the creation of type definitions directly from your database collections, seamlessly integrating with your preferred programming language.

Say goodbye to manual mapping

Manually creating and maintaining complex type definitions can be tedious, error-prone, and time-consuming. With Type generation, Appwrite does the heavy lifting for you. Automatically generate accurate and up-to-date type definitions, ensuring your code always syncs with your database schema.

Effortless multi-language support

Whether you work with PHP, Swift, Dart, TypeScript, JavaScript, Java, or Kotlin, Type generation has you covered. The Appwrite CLI automatically detects your project's language and generates the appropriate type definitions, handling complex scenarios including Enums, class relationships, and language-specific semantics. We will continue to add support for more languages over time.

Simplified workflow, immediate benefits

Using Type generation is straightforward.

First, ensure you have the Appwrite CLI installed and your project is initialised. Then, run the following command in your terminal to pull collections from your Appwrite project:

Bash
appwrite pull collections

To generate types, you can use the Appwrite CLI command:

Bash
appwrite types [options] <output-directory>

To automatically detect the language used in your project, you can skip the [options] parameter.

Bash
appwrite types <output-directory>

Workflow

Better experience

  • Time savings: Eliminate hours of manual work and dedicate your time to building impactful features.
  • Reduced errors: Keep your types consistently aligned with your database schema, drastically reducing outdated and mismatched types.
  • Faster iterations: Automatically propagate schema changes, allowing for rapid development and seamless collaboration.

Built with you in mind

Type generation was built explicitly for developers, addressing key pain points and enhancing your productivity. Whether using Appwrite in a cloud environment or self-hosted, Type generation fits seamlessly into your workflow.

Many other solutions offer type generation limited to TypeScript, Appwrite expands your capabilities with robust multi-language support, ensuring you have flexibility and comprehensive integration, regardless of your preferred technology stack.

By simplifying integration and reducing friction, type generation helps accelerate onboarding and ensures long-term satisfaction, significantly benefiting developer teams and their organizations.

More resources

Frequently asked questions

  • What is Appwrite type generation?

    Type generation is a CLI command that produces type definitions in your project's language directly from your Appwrite collections and tables. It keeps client code in sync with your database schema, reducing the chance of typos and stale types when the schema changes.

  • Which languages does Appwrite type generation support?

    The Appwrite CLI generates types for TypeScript, JavaScript, PHP, Swift, Dart, Java, and Kotlin. The CLI detects your project's language automatically, or you can pass options to specify it explicitly. More languages are added over time.

  • How do I generate types from my Appwrite collections?

    Install the Appwrite CLI, initialize your project, run appwrite pull collections, then run appwrite types <output-directory>. The CLI writes the generated type definitions into the specified folder, ready to import in your application code.

  • Do I need to regenerate types every time my schema changes?

    Yes. After updating columns, indexes, or relationships in your Appwrite Databases, run appwrite pull collections followed by appwrite types to refresh the generated definitions. You can wire this into a CI step or pre-commit hook to keep types current.

  • Why use generated types instead of writing them manually?

    Manual types drift from the schema over time as columns are added, renamed, or removed, leading to subtle runtime bugs. Generation guarantees the types always reflect the current schema, which catches mismatches at compile time and removes a tedious manual sync step from your workflow.

  • Does Appwrite type generation work with self-hosted Appwrite?

    Yes. Type generation works against any Appwrite project the CLI can authenticate to, whether on Appwrite Cloud or self-hosted. The same commands and output formats apply, so your local workflow stays consistent regardless of deployment target.

Start building with Appwrite today