Skip to content

Latest commit

 

History

History
112 lines (79 loc) · 3.73 KB

space.mdx

File metadata and controls

112 lines (79 loc) · 3.73 KB
title description type i18nReady
Deploy your Astro Site to Space
How to build an Astro site in Space.
deploy
true

import InstallGuideTabGroup from '/components/TabGroup/InstallGuideTabGroup.astro'; import PackageManagerTabs from '/components/tabs/PackageManagerTabs.astro'; import { Steps } from '@astrojs/starlight/components';

Deta Space is a personal computer that lives in the cloud — a ‘personal cloud’. You can build and run apps for yourself in your own "Space". You can publish the apps you've built, and they'll run for people all around the world.

This guide includes step-by-step instructions for building sites in Space. Both static and server-side rendered (with the @astrojs/node adapter) Astro sites are supported.

:::note The following instructions will not work for v3.0+ Astro projects as Space currently only supports Node.js 16. :::

Prerequisite

To push an Astro site to Space, make sure you first:

Create a Space project inside the directory of your Astro project. Run the CLI and follow the instructions on the screen.

space new

:::note The Space CLI will try to auto-detect the configuration for your app. Accept the suggested configuration and then follow the instructions below, depending on the type of Astro app you want to deploy. :::

Project Configuration

Static site

Make the following changes to the Spacefile file at the root of your project generated by the Space CLI.

1. Change the engine to `static`.
  1. Add Astro's build command to the list of commands.

  2. Serve the dist directory generated by Astro.

# Spacefile Docs: https://deta.space/docs/en/build/reference/spacefile
v: 0
micros:
  - name: static-astro-in-space
    src: .
    engine: static
    commands:
      - npm run build
    serve: dist

Server-side rendered site

Make the following changes to the Spacefile file at the root of your project generated by the Space CLI:

1. Configure the `nodejs16` engine.
  1. Add the build command.

  2. Include the dist directory generated by Astro.

  3. Run the node command.

# Spacefile Docs: https://deta.space/docs/en/build/reference/spacefile
v: 0
micros:
  - name: ssr-astro-in-space
    src: .
    engine: nodejs16
    commands:
      - npm run build
    include:
      - dist
    run: "node ./dist/server/entry.mjs"

How to deploy

Deploy your project with the following command:

space push

This will run the build process and create a new Space app instance where you can access your Astro app.

By default Space apps are private and are only accessible to you.

If you want to make your app available to others you can use Public Routes to make parts of your app public. Or, you can create a release to let others install your app into their own personal cloud.

Next steps

Examples