> ## Documentation Index
> Fetch the complete documentation index at: https://docs.instapods.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy Astro (SSR on Node)

> Deploy an Astro site with server-side rendering to InstaPods: add the @astrojs/node adapter in standalone mode, paste your GitHub repo, and deploy. No build or start commands to write.

An Astro site that renders on the server runs on InstaPods as a Node.js app. You add the official
Node adapter, paste your GitHub repo into the create-pod wizard, and deploy. InstaPods recognises
the project as Astro, builds it, and starts the standalone server. You don't write a build command,
a start command or a port.

> [card] [Deploy your Astro site](https://app.instapods.com/dashboard/pods/create?utm_source=docs_astro_ssr)
>
> Create a pod from your GitHub repo. A small Astro site runs on the Launch plan (\$3/mo).

## When you need a server

Astro builds static HTML by default, and a static site needs no server at all. Use SSR on Node
when your site has any of these:

* **Pages rendered per request**: personalised pages, pages that read cookies or headers, or
  content that must be fresh on every visit.
* **API endpoints**: `src/pages/api/*.ts` routes that handle form posts, webhooks or JSON requests.
* **Server islands**: components marked `server:defer`, which need a server to render.
* **Data on disk**: a SQLite file or uploads that the site reads and writes at runtime. A pod
  keeps its files between deploys and restarts.

If none of these apply, see [Static Astro sites](#static-astro-sites) below.

## Repo requirements

**1. Add the Node adapter**

From your project root:

```bash theme={null}
npx astro add node
```

Then check that `astro.config.mjs` uses the adapter in `standalone` mode, with `output: 'server'`:

```js astro.config.mjs theme={null}
// @ts-check
import { defineConfig } from 'astro/config';
import node from '@astrojs/node';

export default defineConfig({
  output: 'server',
  adapter: node({ mode: 'standalone' }),
});
```

`standalone` matters. It builds a self-contained server at `dist/server/entry.mjs`, which is
what InstaPods starts. The other mode, `middleware`, expects you to write your own server around it.

**2. Commit your lockfile and push to GitHub**

Commit `package-lock.json` along with your code, and push the repo to GitHub. You don't need a
`start` script in `package.json`. The default Astro scripts (`dev`, `build`, `preview`) are enough.

**3. Don't hardcode a host or port**

Leave the host and port out of `astro.config.mjs` and your code. The standalone server reads
`HOST` and `PORT` from the environment, and InstaPods sets both for you. See
[Environment variables](#environment-variables).

## Deploy

**1. Start a new pod from your repo**

In the [dashboard](https://app.instapods.com/dashboard/pods/create?utm_source=docs_astro_ssr),
click **New pod** and choose **GitHub repo**. Paste the repository URL (the URL only, not a
`git clone` command) and pick the branch.

**2. Keep the detected settings**

The wizard shows **Detected nodejs**, and the **AI analyzed your repo** card is tagged
**Astro**. It suggests install, build and start commands, with `node ./dist/server/entry.mjs`
as the start command. Leave them as they are.

`HOST` and `PORT` may show up as automatic variables. You don't fill them in, and Astro itself
needs no other environment variables.

**3. Pick a name, region and plan**

On **Name, region & plan**, the **Launch** plan (\$3/mo, 512MB) is enough for a small Astro
site. When the server has room, the build gets a temporary memory boost (2GB on Launch), and
the pod drops back to its plan's memory when the build ends.

**4. Deploy**

Click **Deploy now**. If your account has no payment method yet, the button reads
**Continue to payment**, and the pod deploys once you add a card.

A small site builds in well under a minute. The build log shows `Framework: astro (ssr)`, then
`npm install`, `npm run build` and the start command `node dist/server/entry.mjs`. Your site is live at
`https://my-app.<server>.instapods.app`, the URL shown on the pod's overview.

To deploy a new commit, open the pod's **Git** tab and click **Deploy now**. To deploy on every
push instead, see [Auto-deploy on push](https://docs.instapods.com/guides/git-deployment.md#auto-deploy-on-push). It needs your
GitHub account connected or a webhook added.

> [!TIP]
>
> A private repo needs your GitHub account connected first. See
> [Connecting your GitHub account](https://docs.instapods.com/guides/git-deployment.md#connecting-your-github-account).

## Environment variables

InstaPods sets `HOST=0.0.0.0` and `PORT=3000` on every Node.js pod. The standalone server binds to
them, and the platform routes your pod's URL to that port. **Don't set `HOST` or `PORT` yourself**,
in the **Env** tab or in a committed `.env`.

Your own variables (API keys, database URLs) go on the pod's **Env** tab or through
`instapods env set`. Server code reads them from `process.env` at runtime. See
[Environment Variables](https://docs.instapods.com/guides/environment-variables.md) for how they reach the app.

> [!NOTE]
>
> Astro inlines `import.meta.env` values into the build output when the site is built. If you read a
> variable through `import.meta.env`, deploy again after you change it. Values read through
> `process.env` in server code take effect after the app restarts.

## Static Astro sites

A site with no adapter builds to plain HTML in `dist/`. For a repo like that, the wizard's AI
analysis usually recommends the **Static** preset and switches the pod to it.

> [!WARNING]
>
> We're fixing a problem where a static Astro build on the Static preset deploys "successfully" but
> returns **403 Forbidden** at `/`, because the pod serves the project folder instead of `dist/`.
> Until the fix ships, deploy an Astro site with the Node adapter as described above. It serves the
> same pages.

## Troubleshooting

### The deploy succeeded but `/` returns 403 Forbidden

Your Astro site has no adapter and ended up on the **Static** preset, either because the wizard
recommended it or because you picked it. That's the known issue in
[Static Astro sites](#static-astro-sites). Add the Node adapter (`npx astro add node`, with
`output: 'server'` and `mode: 'standalone'`), push, and create the pod again from the repo. This time
it stays on Node.js.

### A static Astro site on the Node.js preset fails with `EACCES`

If an adapter-less Astro site runs on the **Node.js** preset, the install step can fail with:

```text theme={null}
Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/serve'
```

The suggested install command tries to install a static file server globally, which the app user
isn't allowed to do. Don't put an adapter-less Astro site on the Node.js preset. Add the Node
adapter instead, so that Astro brings its own server.

### The site doesn't respond after a deploy

Check that you haven't set `HOST` or `PORT` yourself, and that nothing in your code pins the server
to `localhost` or another port. Then check that the build log shows `Framework: astro (ssr)` and
the start command `node dist/server/entry.mjs`.

For anything else, see [Troubleshooting](https://docs.instapods.com/support/troubleshooting.md#when-a-deploy-fails).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.