5a. Create a new token to authenticate requests to the database:
Terminal window
tursodbtokenscreatestudiocms
5b. Copy the output of the command and set it as the value for CMS_LIBSQL_AUTH_TOKEN.
.env
CMS_LIBSQL_AUTH_TOKEN=eyJhbGciOiJF...3ahJpTkKDw
Make sure you have a libSQL database setup and running. You can use a local installation, a Docker container, or a managed database service such as Turso^.
After running the command, you’ll be prompted to answer a few questions about your project. Once completed, the CLI will create a new Astro project with StudioCMS in the specified directory.
Afterward, you will be prompted to follow the next steps, which includes ensuring your environment variables are set correctly and running the project to complete the setup.
After running the CLI, make sure that your astro.config.mjs fle is correctly configured:
astro.config.mjs
import{defineConfig}from'astro/config';
importnodefrom'@astrojs/node';
importstudioCMSfrom'studiocms';
exportdefaultdefineConfig({
site:'https://demo.studiocms.dev/',
output:'server',
adapter:node({mode:"standalone"}),
integrations:[
studioCMS(),
],
});
Creating a new Astro project
To create a new Astro project, simply run the following command in your terminal:
After running the command, you’ll be prompted to answer a few questions about your project. Once completed, the CLI will create a new Astro project in the specified directory.
You should see a “Liftoff confirmed. Explore your project!” message followed by some recommended next steps.
cd into your new project directory to begin using Astro.
Terminal window
cdmy-project
If you skipped the npm install step during the CLI wizard, then be sure to install your dependencies before continuing.
To add the StudioCMS integration to your project, you’ll need to install the StudioCMS package and it’s dependencies:
After running the command, you’ll be prompted to answer a few questions about your project. Once completed, the CLI will create a new Astro project in the specified directory.
You should see a “Liftoff confirmed. Explore your project!” message followed by some recommended next steps.
cd into your new project directory to begin using Astro.
Terminal window
cdmy-project
If you skipped the npm install step during the CLI wizard, then be sure to install your dependencies before continuing.
To add the StudioCMS integration to your project, you’ll need to install the Astro StudioCMS package and it’s dependencies:
Please note that the site option in the astro.config.mjs file is required for StudioCMS to work correctly. You can set this to your site’s URL or a placeholder URL. (i.e. https://demo.studiocms.dev/ or http://localhost:4321/)
Configure StudioCMS Database dialect Added in beta.31
If you are using a database other than libSQL you will need to configure the db option in your studiocms.config.mjs file to specify the correct dialect.
A utility function to define the StudioCMS config object.
This function is used to define the optional StudioCMS
config object in the Astro project root. The expected file
name is studiocms.config.mjs. And it should be adjacent
to the Astro project's astro.config.mjs file.
StudioCMS will attempt to import this file and use the default
export as the StudioCMS config object automatically if it exists.
Using this function is optional, but it can be useful for IDEs
to provide better intellisense and type checking.
Or any other community plugin that supports rendering content in StudioCMS.
Any of these plugins can be used to render content in StudioCMS. You can use one or more of these plugins in your project, depending on your needs. They can be installed and configured using the StudioCMS config file.
A utility function to define the StudioCMS config object.
This function is used to define the optional StudioCMS
config object in the Astro project root. The expected file
name is studiocms.config.mjs. And it should be adjacent
to the Astro project's astro.config.mjs file.
StudioCMS will attempt to import this file and use the default
export as the StudioCMS config object automatically if it exists.
Using this function is optional, but it can be useful for IDEs
to provide better intellisense and type checking.
This plugin integrates HTML page type support into StudioCMS, providing editor and renderer components.
It resolves configuration options, sets up Astro integrations, and registers the HTML page type for rendering.
@param ― options - Optional configuration for the HTML schema.
@returns ― The StudioCMS plugin configuration object.
Creates a StudioCMS plugin for Markdown page types.
This plugin configures StudioCMS to support Markdown content, including rendering and editing components,
integration with Astro, and optional callout themes. It resolves user-provided options, sets up virtual imports,
and injects necessary styles and scripts for Markdown rendering.
@param ― options - Optional configuration for Markdown schema and rendering behavior.
@returns ― A StudioCMSPlugin instance configured for Markdown support.
A utility function to define the StudioCMS config object.
This function is used to define the optional StudioCMS
config object in the Astro project root. The expected file
name is studiocms.config.mjs. And it should be adjacent
to the Astro project's astro.config.mjs file.
StudioCMS will attempt to import this file and use the default
export as the StudioCMS config object automatically if it exists.
Using this function is optional, but it can be useful for IDEs
to provide better intellisense and type checking.
This plugin integrates HTML page type support into StudioCMS, providing editor and renderer components.
It resolves configuration options, sets up Astro integrations, and registers the HTML page type for rendering.
@param ― options - Optional configuration for the HTML schema.
@returns ― The StudioCMS plugin configuration object.
Creates a StudioCMS plugin for Markdown page types.
This plugin configures StudioCMS to support Markdown content, including rendering and editing components,
integration with Astro, and optional callout themes. It resolves user-provided options, sets up virtual imports,
and injects necessary styles and scripts for Markdown rendering.
@param ― options - Optional configuration for Markdown schema and rendering behavior.
@returns ― A StudioCMSPlugin instance configured for Markdown support.
StudioCMS supports various oAuth authentication providers, utilizing our plugin system to enable the providers you want to use. To get started, you will need to find a plugin for the provider you want to use, or create your own plugin.
For more information about the available oAuth authentication plugins see, Package Catalog
For setting up oAuth providers, they require a callback URL. The callback URL is the path where the provider will redirect the user after authentication.
Thanks to the power of Astro running StudioCMS is as easy as running the dev command for local preview, or building and deploying to your server, for the basics of how to use it locally without building here is what you need to do.
First time Setup (or during updates if the tables schema is updated)
After running the commands, you should see a message indicating that your project is running at localhost:4321. When first setting up StudioCMS, you will prompted to finish configuring StudioCMS at http://localhost:4321/start
After running the command, you should see a message indicating that your project is running at localhost:4321. Open your browser and navigate to http://localhost:4321 to see your Astro project in action.
You can access the StudioCMS dashboard at http://localhost:4321/dashboard by default to manage your content and settings.
Congratulations! 🥳 You now have StudioCMS installed in your Astro project.
StudioCMS is a headless Astro CMS, which means you have to provide your own frontend to display the content. If you are looking for a frontend that is already built, you can checkout our plugins in the Package Catalog.
For example if you want to build a blog using StudioCMS, you can use the @studiocms/blog plugin to get started quickly without having to build everything from scratch. This plugin provides a simple blog frontend that removes the need to have any source files for your frontend pages.
To install and setup the blog plugin, run the following command in your terminal:
A utility function to define the StudioCMS config object.
This function is used to define the optional StudioCMS
config object in the Astro project root. The expected file
name is studiocms.config.mjs. And it should be adjacent
to the Astro project's astro.config.mjs file.
StudioCMS will attempt to import this file and use the default
export as the StudioCMS config object automatically if it exists.
Using this function is optional, but it can be useful for IDEs
to provide better intellisense and type checking.
A utility function to define the StudioCMS config object.
This function is used to define the optional StudioCMS
config object in the Astro project root. The expected file
name is studiocms.config.mjs. And it should be adjacent
to the Astro project's astro.config.mjs file.
StudioCMS will attempt to import this file and use the default
export as the StudioCMS config object automatically if it exists.
Using this function is optional, but it can be useful for IDEs
to provide better intellisense and type checking.
After running the first time setup steps, you should build and deploy your StudioCMS project to your server.
By default, StudioCMS’s dashboard is available at http://your-domain.tld/dashboard.
This dashboard will be available for you to manage your content and settings in development mode and production mode.
It is recommended to use StudioCMS in production mode only, as the dashboard is meant to be used by the built project. (You may see some issues/errors in development mode such as a Vite dep error.)