Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ on:
types: [opened, synchronize, reopened, closed]

jobs:
deploy:
deploy_prod:
runs-on: ubuntu-latest
if: github.event_name == 'push' || github.event.action != 'closed'
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
Expand All @@ -23,14 +23,30 @@ jobs:
CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }}
ALCHEMY_STATE_TOKEN: ${{ secrets.ALCHEMY_STATE_TOKEN }}

deploy_preview:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.action != 'closed'
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run deploy --stage "pr-${{ github.event.pull_request.number }}"
env:
ALCHEMY_PASSWORD: ${{ secrets.ALCHEMY_PASSWORD }}
BETTER_AUTH_URL: ${{ secrets.BETTER_AUTH_URL }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_KEY: ${{ secrets.CLOUDFLARE_API_KEY }}
CLOUDFLARE_EMAIL: ${{ secrets.CLOUDFLARE_EMAIL }}
ALCHEMY_STATE_TOKEN: ${{ secrets.ALCHEMY_STATE_TOKEN }}

cleanup:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.action == 'closed'
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run destroy --stage ${{ github.head_ref }}
- run: bun run destroy --stage "pr-${{ github.event.pull_request.number }}"
env:
ALCHEMY_PASSWORD: ${{ secrets.ALCHEMY_PASSWORD }}
BETTER_AUTH_URL: ${{ secrets.BETTER_AUTH_URL }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
package-lock.json

# Output
.output
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ src/
├── lib/
│ ├── auth.ts # Better Auth configuration
│ ├── auth-client.ts # Auth client setup
│ ├── auth-store.svelte.ts # Auth state management
│ └── schema.ts # Database schema
├── routes/
│ ├── api/auth/[...all]/ # Better Auth API routes
Expand Down
19 changes: 4 additions & 15 deletions alchemy.run.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import alchemy from "alchemy";

import {
SvelteKit,
Worker,
import {
SvelteKit,
Worker,
DurableObjectNamespace,
D1Database
} from "alchemy/cloudflare";
Expand All @@ -13,34 +13,24 @@ import type { CounterDO } from "./worker/index.ts";

const projectName = "remote";

console.log({
stateToken: process.env.ALCHEMY_STATE_TOKEN,
password: process.env.ALCHEMY_PASSWORD,
});

const project = await alchemy(projectName, {
password: process.env.ALCHEMY_PASSWORD || "default-password",
stateStore: (scope) => new CloudflareStateStore(scope, {
scriptName: `${projectName}-ci-state`,
})
stateStore: (scope) => new CloudflareStateStore(scope)
});

const COUNTER_DO = DurableObjectNamespace<CounterDO>(`${projectName}-do`, {
className: "CounterDO",
scriptName: `${projectName}-worker`,
sqlite: true
});

// Create D1 database for auth
const DB = await D1Database(`${projectName}-db`, {
name: `${projectName}-db`,
migrationsDir: "migrations",
adopt: true,
});

// Create the worker
export const WORKER = await Worker(`${projectName}-worker`, {
name: `${projectName}-worker`,
entrypoint: "./worker/index.ts",
adopt: true,
bindings: {
Expand All @@ -50,7 +40,6 @@ export const WORKER = await Worker(`${projectName}-worker`, {
});

export const APP = await SvelteKit(`${projectName}-app`, {
name: `${projectName}-app`,
bindings: {
COUNTER_DO,
WORKER,
Expand Down
247 changes: 134 additions & 113 deletions bun.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
},
"devDependencies": {
"@sveltejs/adapter-cloudflare": "^7.2.4",
"@sveltejs/kit": "^2.48.5",
"@sveltejs/kit": "^2.49.2",
"@sveltejs/vite-plugin-svelte": "^6.2.1",
"@tailwindcss/forms": "^0.5.10",
"@tailwindcss/forms": "^0.5.11",
"@tailwindcss/typography": "^0.5.19",
"@tailwindcss/vite": "^4.1.17",
"alchemy": "^0.77.5",
"better-auth": "^1.3.34",
"drizzle-kit": "^0.31.7",
"drizzle-orm": "^0.44.7",
"svelte": "^5.43.10",
"@tailwindcss/vite": "^4.1.18",
"alchemy": "^0.81.4",
"better-auth": "^1.4.7",
"drizzle-kit": "^0.31.8",
"drizzle-orm": "^0.45.1",
"svelte": "^5.46.0",
"svelte-check": "^4.3.4",
"tailwindcss": "^4.1.17",
"tailwindcss": "^4.1.18",
"typescript": "^5.9.3",
"vite": "^7.2.2",
"wrangler": "^4.47.0"
"vite": "^7.3.0",
"wrangler": "^4.56.0"
},
"description": "Barebones starter for authenticated apps with persistent edge state - SvelteKit + Better Auth + Durable Objects",
"keywords": ["sveltekit", "better-auth", "cloudflare", "durable-objects", "alchemy", "remote-functions", "typescript"],
Expand Down
1 change: 0 additions & 1 deletion packages/create-remote-app/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ src/
├── lib/
│ ├── auth.ts # Better Auth configuration
│ ├── auth-client.ts # Auth client setup
│ ├── auth-store.svelte.ts # Auth state management
│ └── schema.ts # Database schema
├── routes/
│ ├── api/auth/[...all]/ # Better Auth API routes
Expand Down
10 changes: 3 additions & 7 deletions packages/create-remote-app/template/alchemy.run.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import alchemy from "alchemy";

import {
SvelteKit,
Worker,
import {
SvelteKit,
Worker,
DurableObjectNamespace,
D1Database
} from "alchemy/cloudflare";
Expand All @@ -20,20 +20,17 @@ const project = await alchemy(projectName, {
// Replace "MyDO" with your actual Durable Object class name
const MY_DO = DurableObjectNamespace(`${projectName}-do`, {
className: "MyDO", // Change this to your DO class name
scriptName: `${projectName}-worker`,
sqlite: true
});

// Create D1 database for auth (required for Better Auth)
const DB = await D1Database(`${projectName}-db`, {
name: `${projectName}-db`,
migrationsDir: "migrations",
adopt: true,
});

// Create the worker that hosts your Durable Objects
export const WORKER = await Worker(`${projectName}-worker`, {
name: `${projectName}-worker`,
entrypoint: "./worker/index.ts",
adopt: true,
bindings: {
Expand All @@ -44,7 +41,6 @@ export const WORKER = await Worker(`${projectName}-worker`, {

// Create the SvelteKit app
export const APP = await SvelteKit(`${projectName}-app`, {
name: `${projectName}-app`,
bindings: {
MY_DO, // Make your DO available to SvelteKit
WORKER, // Make worker available for service bindings
Expand Down
Loading
Loading