Kickstart Astro is a minimal starter that connects Astro applications to Contentstack. The repository uses server-side rendering (SSR) with output:"server" and the @astrojs/node adapter in standalone mode. For more background, see SSR.
Use this starter to set up an Astro app that connects to Contentstack with these preconfigured features:
In this guide, you:
Before you begin, make sure you have the following:
Note: Kickstart projects use a shared content model. You can reuse one stack across projects, or create separate stacks for isolated content and configuration.
With these basics in place, choose the setup path that matches your workflow.
Use one of the following paths to create a stack with the content model and sample entries that Kickstart Astro expects.
Use these guides to complete setup:
Typical outcomes
If you use Launch, note that variable names often use prefixes such as CONTENTSTACK_*. For local development in this repository, you will later map those values to PUBLIC_CONTENTSTACK_* keys in .env.
Once your stack or deployment is ready, continue with the local clone and configuration steps below.
The Kickstart Astro project expects content from the shared seed repository contentstack/kickstart-stack-seed. Seeding that repository with the CLI produces the same outcome as a Starter import for local and repeatable setups, such as onboarding or CI.
This approach works well for terminal-first workflows or when you do not use the Marketplace onboarding path.
Note: If you already created a stack from this seed, or from another compatible Kickstart project, you can reuse that stack and skip creating another one.
npm install -g @contentstack/cli
csdx config:set:region EUNote: Free developer stacks typically use the EU region. Refer to the About Regions document to know more about Contentstack regions.
csdx auth:logincsdx cm:stacks:seed --repo "contentstack/kickstart-stack-seed" --org "<ORG_ID>" -n "Kickstart Stack"After the process completes, the CLI creates a stack, imports the Kickstart content models, and adds sample entries.
Additional Resources:
Once the seed completes, continue with the local clone and configuration steps below.
For local development, clone the repository you plan to run:
git clone https://github.com/contentstack/kickstart-astro.git
cd kickstart-astroIn the cloned project folder, run:
npm install
This command installs dependencies to run and build the app locally.
With the local project ready, gather the stack credentials you need for .env.
Gather these values before you update .env. Use the stack you created through the Starter or CLI path earlier. Create a new stack manually only if you are not using those paths. For manual setup, see Create a new stack.
Additional Resource: Refer to the Create a Delivery Token document for detailed steps.
Once you have these values, add them to the local environment file.
After you have a stack, the required tokens, and a local clone, connect the app to Contentstack.
PUBLIC_CONTENTSTACK_API_KEY=<STACK_API_KEY>
PUBLIC_CONTENTSTACK_DELIVERY_TOKEN=<DELIVERY_TOKEN>
PUBLIC_CONTENTSTACK_PREVIEW_TOKEN=<PREVIEW_TOKEN>
PUBLIC_CONTENTSTACK_ENVIRONMENT=preview
PUBLIC_CONTENTSTACK_REGION=EU
PUBLIC_CONTENTSTACK_PREVIEW=trueNote: When you set PUBLIC_CONTENTSTACK_PREVIEW=true, the app enables Live Preview behavior in code paths that read this flag.
Note: Free Contentstack developer accounts are commonly bound to the EU region. The CDN routes API requests for responsiveness, but you still need to set PUBLIC_CONTENTSTACK_REGION to match your stack.
This project uses Astro with Vite. Variables prefixed with PUBLIC_ are available as import.meta.env.PUBLIC_* in server and client code, as described in Astro environment variables. No separate script generates TypeScript environment files from .env. The app reads configuration at development time and build time from .env, and it can read the same names from the process environment in CI.
You can override the default API hosts with these optional variables. The code supports them even if .env.example does not include them:
If you omit these variables, @timbenniks/contentstack-endpoints() resolves hosts from PUBLIC_CONTENTSTACK_REGION.
Warning: Do not commit .env to version control. It should remain listed in .gitignore.
With local configuration in place, enable Live Preview in the stack so the CMS and app use matching settings.
Additional Resource: For detailed setup instructions, refer to Set Up Live Preview for Your Stack.
Run the app, and confirm that it loads content from your stack.
npm run dev
You should see the homepage with:
Prerequisites to Test Live Preview
Steps
This happens because initLivePreview() in src/lib/contentstack.ts wires the app to Contentstack Live Preview update events, so preview content refreshes when entries change.
Tip: Open the entry in the CMS, and then use the Live Preview entry point or Visual Editor so the app runs within the CMS for click-to-edit workflows.
The sections below show where the main integration points live after setup is working.
After you install dependencies, the repository follows this structure:
kickstart-astro/
├── src/
│ ├── layouts/
│ │ └── Layout.astro
│ ├── lib/
│ │ ├── contentstack.ts
│ │ └── types.ts
│ ├── env.d.ts
│ ├── pages/
│ │ └── index.astro
│ └── styles/
│ └── global.css
├── public/
│ └── favicon.svg
├── .env.example
├── astro.config.mjs
├── package.json
├── package-lock.json
├── tsconfig.json
├── LICENSE
├── README.md
├── SECURITY.md
├── .github/ # CI and repository metadata
├── .vscode/ # Optional editor recommendations
└── .talismanrc # Security scanning configUse these checks if the homepage is empty, the SDK cannot authenticate, or Live Preview does not update as expected.
The application expects the page content type and sample entries from the Kickstart stack seed or an equivalent Starter. If the model or entries are missing, the home page may appear empty or fail to resolve /.
The project reads PUBLIC_CONTENTSTACK_* variables. If .env is missing, or if the keys do not use the correct Astro prefix, import.meta.env values are empty, and the SDK cannot authenticate.
Local Astro uses http://localhost:4321/ by default. Hosted apps must use the real deployment URL. If you use the wrong origin, Live Preview and Visual Editor break even when delivery works.
Enable Live Preview under Settings, and select the environment that matches PUBLIC_CONTENTSTACK_ENVIRONMENT.
Warning: The file contains secrets. Keep it out of git and rely on .gitignore.
Use the correct tokens from the stack, or map the correct values from Launch.
PUBLIC_CONTENTSTACK_ENVIRONMENT must match an environment that exists in your stack.
Install dependencies after you clone the repository so scripts and types resolve correctly.
The app reads from the environment named in .env. Content that is unpublished or published to a different environment does not appear.
getPage() queries the page content type and matches the URL to the path (e.g., /). If you rename fields or content types in the stack, update the query and types accordingly.
For questions or issues, join the Contentstack Community on Discord.