App SDK

App SDK Quickstart Guide

Get up and running quickly with the Sanity App SDK by following this step-by-step guide!

1Create a new App SDK app

Initialize a new project by running npx sanity@latest:

When prompted:

  • Select yes when asked to install the sanity package
  • Choose your organization, or create a new one
  • Specify a location to save your project locally
  • Choose whether you want to work with TypeScript or JavaScript

Once you've worked through these options, the CLI should proceed to install all the necessary dependencies, and report back with a confirmation.

2Navigate to the project directory

If you chose to install your project in a folder different to the current directory, such as a sub-folder, navigate into the project root.

3Inspect the project folder

In your favorite editor, open the project root and have a look around. Note the sanity.cli.ts, App.tsx, and ExampleComponent.tsx files in particular.

JS|TS|JSX|TSX

sanity.cli.ts

This is the main configuration for your project . By default, it contains the unique ID for your organization, and the entrypoint for your app.

src/App.tsx

This is the main entrypoint for your application. It contains the <SanityApp /> context provider, and demonstrates how to connect your application to an existing Sanity project. The <SanityApp /> component provides child components with the necessary context to use the SDK React hooks to interact with the content in your project.

Before moving on, modify the config variable to include the projectId and dataset for the Sanity project you’d like to work with in your custom app.

src/ExampleComponent.tsx

This component just displays some static content to welcome you to your project. Feel free to get rid of it, or use it as a springboard to write something cooler.

4Start the development server

It's time to actually run the app! Enter the following command in your terminal:

You should see the CLI reporting on its progress.

Once having successfully launched your app, the CLI will provide you with a URL where you can see it running locally in the Sanity Dashboard. Open this link in your browser to see the Dashboard frontpage, then locate your application in the sidebar.

a welcome to your sanity app pagea welcome to your sanity app page

5Deploy your app

Finally, when you are happy with your custom app, it's time to deploy it. Run the following command:

Your custom app will be deployed and made available in your organization dashboard.

6Troubleshooting

If you see an error about the port being in use:

  • Kill any existing process using port 3333, or
  • Start the dev server on a different port:

If you see an error about missing authorization:

  • Make sure your user account has the appropriate privileges
  • Log out and back in to Sanity

7Next steps

Was this page helpful?