Skip to content

Commit 8afd0a5

Browse files
committed
Add page about self hosting
1 parent bc1bcfb commit 8afd0a5

4 files changed

Lines changed: 105 additions & 2 deletions

File tree

‎docs/about/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ In Nordcraft, both developers and designers can collaborate. When building in No
2929
- [Asset management for uploading, storing and resizing media](/media/overview)
3030
- [SEO and meta tag configuration tools](/pages/page-configuration#metadata)
3131
- Pre-built templates to get you started quickly
32-
- Deploy directly to Nordcraft's infrastructure or self-host your projects
32+
- Deploy directly to Nordcraft's infrastructure or [self-host your projects](/self-hosting)
3333

3434
## The Nordcraft community
3535

‎docs/get-started/project-details/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The following actions are available for each branch:
5555
- **View changes**: See an overview of all modifications in the branch; if the branch is outdated, conflicts will be highlighted for resolution before syncing with the main branch
5656
- **Preview**: Opens the live version of the branch
5757
- **Delete branch**: Deletes selected branch
58-
- **Download branch**: Download the branch code in JSON format
58+
- **Download branch**: Download the branch code in JSON format (for backups or [self-hosting](/self-hosting))
5959

6060
## Version history
6161

‎docs/index.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@
328328
]
329329
},
330330
{ "path": "custom-domains", "label": "Custom domains" },
331+
{ "path": "self-hosting", "label": "Self-hosting" },
331332
{
332333
"path": "packages",
333334
"label": "Packages",

‎docs/self-hosting/index.md‎

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
title: Self-hosting
3+
description: Learn how to self-host your Nordcraft website on your own server, Docker, or Cloudflare Workers using the open-source Nordcraft backend.
4+
---
5+
6+
# Self-hosting
7+
8+
By default, Nordcraft hosts your websites on Nordcraft's infrastructure. Because Nordcraft is open source, you can also export your project and **self-host** it on your own infrastructure using the open-source backend package in the [Nordcraft GitHub repository](https://github.com/nordcraftengine/nordcraft/tree/main/packages/backend).
9+
10+
::: info
11+
The Nordcraft self-hosting backend package is still under active development. Check the [Nordcraft repository on GitHub](https://github.com/nordcraftengine/nordcraft/tree/main/packages/backend) for the latest updates and improvements.
12+
:::
13+
14+
## What is included
15+
16+
When you self-host a Nordcraft website with the `@nordcraft/backend` package, your site runs with the core features you get on Nordcraft's hosting:
17+
18+
- **Server-side rendering (SSR)**: Pages are rendered on the server for fast initial load times and search engine optimization (SEO), then hydrated in the browser for interactivity.
19+
- **Custom formulas and actions**: Your project's custom formulas and actions work during both server-side rendering and in the browser.
20+
- **Redirects and proxies**: Handles the [redirects](/pages/redirects) and [proxies](/pages/proxies) configured in your project.
21+
- **API requests and cookies**: Proxies client API requests and supports [HTTP-only cookies](/connecting-data/authentication) for authentication.
22+
- **Fonts and site files**: Serves Google Fonts, page stylesheets, exported [custom elements](/components/export-a-component), `/sitemap.xml`, `/robots.txt`, `/manifest.json`, and `/favicon.ico` based on your project configuration.
23+
24+
## Before you start
25+
26+
To self-host a Nordcraft website, you need:
27+
28+
- A Nordcraft website project that you want to host
29+
- [Bun](https://bun.sh/) installed on your computer to install dependencies and prepare your project
30+
- A hosting provider if you plan to publish online, such as [Cloudflare Workers](https://workers.cloudflare.com/), [Docker](https://www.docker.com/), or a server running Bun or Node.js
31+
32+
## Export and set up your project
33+
34+
Follow these steps to export your website from Nordcraft and add it to the backend package:
35+
36+
1. Open your project in Nordcraft and go to the [Project details](/get-started/project-details#branches) page.
37+
2. Find the branch you want to host (usually `main`), open its actions menu, and select **Download branch** to save your project as a JSON file.
38+
3. Clone the [Nordcraft repository](https://github.com/nordcraftengine/nordcraft) from GitHub, install the dependencies, and build the workspace packages from the root folder:
39+
40+
```bash
41+
git clone https://github.com/nordcraftengine/nordcraft.git
42+
cd nordcraft
43+
bun install
44+
bun run build
45+
```
46+
47+
4. Move the JSON file you downloaded from Nordcraft into `packages/backend/__project__/project.json`, replacing the example `project.json` file.
48+
49+
::: tip
50+
Your self-hosted site serves the snapshot you exported in `project.json`. Whenever you publish new changes in Nordcraft, download the updated branch, replace `project.json`, and redeploy.
51+
:::
52+
53+
## Run locally
54+
55+
Before deploying to a live server, you can test your self-hosted website locally. Navigate to the backend folder and start the development server:
56+
57+
```bash
58+
cd packages/backend
59+
bun run dev
60+
```
61+
62+
This prepares your project's pages and static assets and starts a local server so you can preview your site in your browser.
63+
64+
If you want to test the compiled production server locally, you can also run it directly with Bun (`bun run bunrun`) or Node.js (`bun run noderun`).
65+
66+
## Deploy your website
67+
68+
Once your project is set up in `packages/backend`, you can deploy it to Cloudflare Workers or package it with Docker to run on any server.
69+
70+
### Deploy to Cloudflare Workers
71+
72+
The backend package comes pre-configured for [Cloudflare Workers](https://workers.cloudflare.com/) in `packages/backend/wrangler.toml`.
73+
74+
1. Provide your Cloudflare account ID by setting the `CLOUDFLARE_ACCOUNT_ID` environment variable or adding it to `packages/backend/wrangler.toml`.
75+
2. Deploy your website from the `packages/backend` folder:
76+
77+
```bash
78+
bun run deploy
79+
```
80+
81+
This command prepares your project's static assets, bundles the application, and publishes it to Cloudflare Workers.
82+
83+
### Deploy with Docker
84+
85+
If you want to host your website on your own server or any container platform, use the included `Dockerfile` to build and run a lightweight container.
86+
87+
From the `packages/backend` folder, run:
88+
89+
```bash
90+
bun run docker:build
91+
bun run docker:run
92+
```
93+
94+
By default, the container serves your website on port `3000`.
95+
96+
## Best practices
97+
98+
Keep the following in mind when running a self-hosted Nordcraft website:
99+
100+
- **Use HTTPS in production**: Serve your public website over HTTPS so features like [HTTP-only cookies](/connecting-data/authentication) work properly in browsers.
101+
- **Keep secrets out of your project**: Never store private API keys or sensitive credentials in your Nordcraft project. Read the [Security guide](/guides/security) to learn how to handle sensitive data safely.
102+
- **Keep your export in sync**: Self-hosted websites do not automatically update when you edit your project in Nordcraft. Re-export your branch and redeploy whenever you want changes to go live.

0 commit comments

Comments
 (0)