# Get the website code

> Pick a starter, get its code on GitHub with this space's settings filled in, deploy it to Vercel or Netlify, connect the preview and check that the website is connected.

Source: https://docs.bifrostorbit.com/cms/developers/get-the-website-code/

A template gives a space its content: content types, components and sample pages. A starter is the code of a website or app that shows that content. **Configuration › Website code** brings the two together: it picks the right starter for the space, fills in the settings and checks the result, so nobody copies keys and addresses across by hand.

A new space opens on this page as soon as the wizard has created it. Choose **Open the space** to come back later. Every plan has it.

## Who can do what

| Step | Who |
| --- | --- |
| See the page and copy the settings | Developer, Administrator or Owner |
| Create keys on the page | Anyone who can create API keys: Developer, Administrator or Owner |
| Save the Preview URL | Administrator or Owner, as in **Settings** |
| Check the connection | Anyone who can see the page |

## 1. Choose a starter

The page recommends the **website starter** for a space made from a template. It is a finished Next.js website that draws every component the templates use, so the sample Northwilds pages look right from the first deploy. For a space started from scratch it recommends the Next.js starter.

The other starters are the finished code of each [quickstart](https://docs.bifrostorbit.com/cms/developers/quickstarts/): React, Astro, Nuxt, Vue, SvelteKit, Angular, Laravel, Symfony, and apps for Apple platforms and Android. They draw only their own example components, so a template's pages show their blocks once you add components for them.

## 2. Add the settings

Choose the environment the website reads, and the region. Start with **Staging**, so editors can preview drafts on it. The page lists every setting the starter reads, under the starter's own names, such as `CMS_API_URL` for Next.js or `NUXT_CMS_API_URL` for Nuxt:

- **API address and region:** filled in, with a button to copy each.
- **Public key** (`cms_pk_`): choose **Create a public key**. It reads published content only.
- **Preview key** (`cms_sk_`): choose **Create a preview key**, for Staging only. It reads drafts, so it stays on the website's server and never goes into the browser, an app or a link. The live website never gets one.
- **Webhook secret:** after the first deploy, create a webhook to the route the page names, such as `/api/revalidate`, and paste its secret. See [Refresh the website when content changes](https://docs.bifrostorbit.com/cms/developers/webhooks/).

A key is shown once. The page also writes the whole settings file, such as `.env.local`, with the keys you created, ready to copy. Never commit it. If the environment already has keys you still have, use those instead.

## 3. Get the code

- **Use this template on GitHub** opens GitHub's form for a new repository made from the starter.
- **Deploy with Vercel** is there for the website starter, Next.js and Nuxt, and **Deploy to Netlify** for Nuxt. Each copies the starter to your GitHub and deploys it.

The deploy buttons fill in the API address and region. They ask for the public key, which you paste from step 2: keys never go in a link, because links end up in browser history and logs. Add the preview key in the project's settings afterwards. For the other starters, deploy them as any other project of their framework; see [Deploy your website](https://docs.bifrostorbit.com/cms/developers/deploy-your-website/).

## 4. Connect the preview

Paste the staging website's address, such as `https://stage.northwilds.com`, and choose **Save**. It is the same **Preview URL** as in the space's [settings](https://docs.bifrostorbit.com/cms/editors/space-settings/), so editors now see the real website beside each page. Developers who can't save it send the address to an Administrator or Owner.

Apps have no Preview URL: their drafts go through a server of your own, as the [Apple](https://docs.bifrostorbit.com/cms/developers/quickstart-apple/) and [Android](https://docs.bifrostorbit.com/cms/developers/quickstart-android/) quickstarts show.

## 5. Check the connection

Choose **Check the website**. CMS Orbit opens a page of the Preview URL with a preview link that works for 2 minutes, the way the editor does, and reports:

| Result | What it means |
| --- | --- |
| The website answers | The address is public, uses `https` and answers without an error. |
| The website checked the preview link | The website asked CMS Orbit whether the preview link is valid, so drafts show in the editor. If it didn't, the preview key or the preview route is missing, or the website's API address points elsewhere. |
| The editor may show the website | The website doesn't refuse to be framed. If it does, remove `X-Frame-Options` and allow the editor in `frame-ancestors` on the staging website, as in [Deploy your website](https://docs.bifrostorbit.com/cms/developers/deploy-your-website/). |
| A key last read content | When a key of the environment last read content, which shows that the website reads published pages. |

The check needs a page in the environment to preview. Template spaces have sample pages in Staging; in a space started from scratch, add a **TEMP** page first and delete it afterwards.

## When the live website is ready

Do the same for **Production** on this page: create a public key there and add it to the live website's settings. The live website gets no preview key, and its address goes in **Configuration › Domains**, not the Preview URL. See [Deploy your website](https://docs.bifrostorbit.com/cms/developers/deploy-your-website/) for the go-live checklist.

## Deploy after publishing

If the website is built ahead of time on Vercel or Netlify, **Deploy after publishing** at the bottom of this page starts a deploy after content is published, for each environment you choose. Vercel or Netlify is connected once in Orbit, under **Connections**. The page shows when the last deploy started and, with a token for reading deploys, how it went. See [Deploy your website after publishing](https://docs.bifrostorbit.com/cms/editors/publish-and-schedule/).
