Skip to content

Commit 314ce5b

Browse files
committed
docs: restructure documentation with proven hierarchy
- Rewrite landing page (remove "edge" claims, add value props) - Add quickstart guide for onboarding - Reorganize nav: Getting Started, Workers, Bindings, Examples, Reference, Deployment, Architecture - Create examples index with 3 new examples (hello-world, form-handling, authentication) - Merge environment-variables into bindings overview - Expand custom-domains with SSL, apex domains, troubleshooting - Add table of contents to runtime APIs - Remove obsolete online-editor section
1 parent e4ceec6 commit 314ce5b

File tree

12 files changed

+603
-119
lines changed

12 files changed

+603
-119
lines changed

src/lib/docs-nav.ts

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,61 @@ export interface NavItem {
66

77
export const docsNav: NavItem[] = [
88
{
9-
name: 'Introduction',
9+
name: 'Getting Started',
1010
path: '/docs',
1111
children: [
1212
{ name: 'Overview', path: '/docs' },
13-
{ name: 'Runtime', path: '/docs/runtime' },
14-
{ name: 'Custom domains', path: '/docs/custom-domains' },
15-
{ name: 'Online editor', path: '/docs/online-editor' },
16-
{ name: 'Environment variables', path: '/docs/environment-variables' },
17-
{ name: 'Limits & Quotas', path: '/docs/limits' },
18-
{ name: 'Self-Hosting', path: '/docs/self-hosting' }
13+
{ name: 'Quick Start', path: '/docs/quickstart' }
14+
]
15+
},
16+
{
17+
name: 'Workers',
18+
path: '/docs/workers',
19+
children: [
20+
{ name: 'HTTP Handlers', path: '/docs/workers/event-fetch' },
21+
{ name: 'Scheduled Tasks', path: '/docs/workers/scheduled-tasks' }
1922
]
2023
},
2124
{
2225
name: 'Bindings',
2326
path: '/docs/bindings',
2427
children: [
2528
{ name: 'Overview', path: '/docs/bindings' },
26-
{ name: 'Storage', path: '/docs/bindings/storage' },
2729
{ name: 'KV', path: '/docs/bindings/kv' },
30+
{ name: 'Storage', path: '/docs/bindings/storage' },
2831
{ name: 'Database', path: '/docs/bindings/database' }
2932
]
3033
},
31-
{
32-
name: 'Workers',
33-
path: '/docs/workers',
34-
children: [
35-
{ name: 'Handle HTTP requests', path: '/docs/workers/event-fetch' },
36-
{ name: 'Scheduled tasks', path: '/docs/workers/scheduled-tasks' }
37-
]
38-
},
3934
{
4035
name: 'Examples',
4136
path: '/docs/examples',
4237
children: [
38+
{ name: 'Overview', path: '/docs/examples' },
39+
{ name: 'Hello World', path: '/docs/examples/hello-world' },
4340
{ name: 'JSON API', path: '/docs/examples/json-api' },
44-
{ name: 'Redirect Service', path: '/docs/examples/redirect' },
41+
{ name: 'Form Handling', path: '/docs/examples/form-handling' },
42+
{ name: 'Authentication', path: '/docs/examples/authentication' },
4543
{ name: 'CORS Proxy', path: '/docs/examples/cors-proxy' },
44+
{ name: 'Redirect Service', path: '/docs/examples/redirect' },
4645
{ name: 'Telegram Bot', path: '/docs/examples/telegram' },
4746
{ name: 'S3 Proxy', path: '/docs/examples/s3-proxy' },
48-
{ name: 'S3 Proxy (AWS v4)', path: '/docs/examples/s3-proxy-aws-v4' }
47+
{ name: 'S3 Proxy (v4)', path: '/docs/examples/s3-proxy-aws-v4' }
48+
]
49+
},
50+
{
51+
name: 'Reference',
52+
path: '/docs/runtime',
53+
children: [
54+
{ name: 'Runtime APIs', path: '/docs/runtime' },
55+
{ name: 'Limits', path: '/docs/limits' },
56+
{ name: 'Custom Domains', path: '/docs/custom-domains' }
57+
]
58+
},
59+
{
60+
name: 'Deployment',
61+
path: '/docs/self-hosting',
62+
children: [
63+
{ name: 'Self-Hosting', path: '/docs/self-hosting' }
4964
]
5065
},
5166
{

src/routes/docs/+page.md

Lines changed: 23 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,31 @@
1-
# About OpenWorkers
1+
# OpenWorkers
22

3-
OpenWorkers is a serverless runtime environment that allows you to run your code without having to worry about the underlying infrastructure.
3+
Serverless JavaScript runtime. Self-hosted, open source, Cloudflare Workers compatible.
44

5-
## Features
6-
7-
- **Fast** - OpenWorkers is built on top of the javascript V8 engine.
8-
- **Secure** - Each worker runs in its own V8 isolate, which means that your code is isolated from other workers.
9-
- **Easy to use** - OpenWorkers is designed to be easy to use, so you can focus on writing your code while we take care of the rest.
10-
11-
## Getting started
12-
13-
To get started, you need to create an account. You can do this by clicking the "Sign in" button in the top right corner of the page.
14-
15-
You will then be redirected to the sign in page. Sign in with your GitHub account.
16-
17-
After logging in, you will be redirected to the dashboard. Here you can see all your workers and create new ones.
18-
19-
### Creating a worker
20-
21-
To create a worker, click the "Create a worker" button in the top right corner of the page.
22-
23-
Here you can enter the name of the worker and select a language template.
24-
25-
The name of the worker must be unique and can only contain letters, numbers and dashes, it will be deployed to `https://<worker-name>.workers.rocks`.
26-
27-
### Editing a worker
28-
29-
To edit a worker, click the "Edit" button in worker overview page.
30-
31-
Here you can edit the code of the worker.
32-
33-
The default returns a "Hello World" html page.
5+
## Quick Example
346

357
```typescript
36-
addEventListener('fetch', (event: FetchEvent) => {
37-
event.respondWith(handleRequest(event.request).catch((err: Error) => new Response(err.stack, { status: 500 })));
38-
});
39-
40-
// More examples available at: https://openworkers.com/docs
41-
async function handleRequest(request: Request): Promise<Response> {
42-
const { pathname } = new URL(request.url);
43-
44-
// Return a 404 response for requests to /favicon.ico.
45-
if (pathname.startsWith('/favicon.ico')) {
46-
return new Response('Not found', { status: 404 });
8+
export default {
9+
async fetch(request: Request, env: Env): Promise<Response> {
10+
const data = await env.KV.get('config');
11+
return Response.json({ data });
4712
}
13+
};
14+
```
4815

49-
// Return a JSON response for requests to /api containing the requested pathname.
50-
if (pathname.startsWith('/api')) {
51-
return new Response(JSON.stringify({ pathname }), {
52-
headers: { 'Content-Type': 'application/json' }
53-
});
54-
}
16+
## What You Get
5517

56-
// Return a HTML response for all other requests.
57-
return new Response('<h3>Hello world!</h3>', {
58-
headers: { 'Content-Type': 'text/html' }
59-
});
60-
}
61-
```
18+
- **V8 Isolates** — Millisecond cold starts, memory-safe sandboxing
19+
- **Standard APIs** — Fetch, Streams, Crypto, Web APIs you already know
20+
- **Bindings** — Connect to databases, storage, KV without exposing credentials
21+
- **TypeScript** — First-class support, no build step required
22+
23+
## Next Steps
6224

63-
From now on, you can edit the code of the worker and it will be automatically deployed.
25+
| | |
26+
|---|---|
27+
| [Quick Start](/docs/quickstart) | Deploy your first worker in 5 minutes |
28+
| [Workers](/docs/workers/event-fetch) | HTTP handlers and scheduled tasks |
29+
| [Bindings](/docs/bindings) | Storage, KV, Database connections |
30+
| [Runtime APIs](/docs/runtime) | Full API reference |
31+
| [Self-Hosting](/docs/self-hosting) | Run on your own infrastructure |

src/routes/docs/bindings/+page.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ Bindings connect your worker to external resources. They're injected via the `en
44

55
## Variables & Secrets
66

7-
Environment variables for configuration.
7+
Environment variables for configuration. Set them in the **Environments** tab of the dashboard.
88

99
```javascript
10-
const apiUrl = env.API_URL; // Variable (visible)
10+
const apiUrl = env.API_URL; // Variable (visible in logs)
1111
const apiKey = env.API_KEY; // Secret (hidden in logs)
1212
```
1313

14-
Configure in **Environments** in the dashboard.
15-
16-
See [Environment Variables](/docs/environment-variables) for setup.
14+
**Variables** are visible in logs. **Secrets** are masked.
1715

1816
---
1917

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,49 @@
1-
# Custom domains
1+
# Custom Domains
22

3-
You can add a custom domain to your worker in the "Domains" section of the worker overview page.
3+
Route your own domain to a worker.
44

5-
For example, for `example.com` to points to your worker, add `example.com` to the "Domains" section.
5+
## Setup
66

7-
Then, add a CNAME record to your DNS provider pointing to `workers.rocks`.
7+
1. Go to your worker's **Domains** tab
8+
2. Add your domain (e.g., `api.example.com`)
9+
3. Add a CNAME record at your DNS provider:
810

9-
Requests to `example.com` will now be routed to your worker.
11+
```
12+
api.example.com CNAME workers.rocks
13+
```
14+
15+
4. Wait for DNS propagation (up to 24h, usually minutes)
16+
17+
## SSL/TLS
18+
19+
SSL certificates are provisioned automatically. Your domain will be accessible via HTTPS.
20+
21+
## Apex Domains
22+
23+
For apex domains (`example.com` without subdomain), use one of:
24+
25+
- **ALIAS record** (if your DNS supports it)
26+
- **A record** pointing to our IP (contact support)
27+
- **Subdomain redirect** from `example.com``www.example.com`
28+
29+
## Multiple Domains
30+
31+
A worker can have multiple domains. All domains route to the same worker code.
32+
33+
## Wildcard Domains
34+
35+
Not currently supported. Create separate workers for each subdomain.
36+
37+
## Troubleshooting
38+
39+
**Domain not resolving:**
40+
- Verify CNAME is set correctly: `dig api.example.com CNAME`
41+
- DNS propagation can take time
42+
43+
**SSL certificate error:**
44+
- New domains may take a few minutes for certificate provisioning
45+
- Ensure the domain resolves correctly first
46+
47+
**404 on custom domain:**
48+
- Check the domain is added in the worker's Domains tab
49+
- Verify the worker is deployed and working on the default URL

src/routes/docs/environment-variables/+page.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/routes/docs/examples/+page.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Examples
2+
3+
Copy-paste examples to get started quickly. Each example is self-contained and ready to deploy.
4+
5+
## Beginner
6+
7+
| Example | Description |
8+
|---------|-------------|
9+
| [Hello World](/docs/examples/hello-world) | Minimal worker, routing basics |
10+
| [JSON API](/docs/examples/json-api) | REST endpoints, request/response handling |
11+
| [Form Handling](/docs/examples/form-handling) | Parse form data, file uploads |
12+
13+
## Intermediate
14+
15+
| Example | Description |
16+
|---------|-------------|
17+
| [Authentication](/docs/examples/authentication) | JWT validation, protected routes |
18+
| [CORS Proxy](/docs/examples/cors-proxy) | Proxy requests with CORS headers |
19+
| [Redirect Service](/docs/examples/redirect) | URL shortener with KV storage |
20+
21+
## Advanced
22+
23+
| Example | Description |
24+
|---------|-------------|
25+
| [Telegram Bot](/docs/examples/telegram) | Webhook handler for Telegram |
26+
| [S3 Proxy](/docs/examples/s3-proxy) | Stream files from S3 (v2 signing) |
27+
| [S3 Proxy (AWS v4)](/docs/examples/s3-proxy-aws-v4) | Stream files from S3 (v4 signing) |

0 commit comments

Comments
 (0)