create-usebecky 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +80 -2
  2. package/dist/create.js +842 -0
  3. package/dist/extension-skill/usebecky-extension/SKILL.md +181 -0
  4. package/dist/extension-skill/usebecky-extension/references/accounts.md +125 -0
  5. package/dist/extension-skill/usebecky-extension/references/dev-server.md +102 -0
  6. package/dist/extension-skill/usebecky-extension/references/manifest.md +104 -0
  7. package/dist/extension-skill/usebecky-extension/references/oauth-and-tokens.md +179 -0
  8. package/dist/extension-skill/usebecky-extension/references/partner-api.md +87 -0
  9. package/dist/extension-skill/usebecky-extension/references/submit-and-pricing.md +31 -0
  10. package/dist/extension-skill/usebecky-extension/references/ui.md +172 -0
  11. package/dist/extension-skill/usebecky-extension/references/webhooks.md +97 -0
  12. package/dist/index.js +10 -0
  13. package/dist/keys.js +72 -0
  14. package/dist/platform.js +104 -0
  15. package/dist/pm.js +69 -0
  16. package/dist/prompts.js +242 -0
  17. package/dist/scaffold.js +108 -0
  18. package/dist/setup.js +130 -0
  19. package/dist/shared/ai.js +203 -0
  20. package/dist/shared/extension-skill.js +107 -0
  21. package/dist/shared/framework.js +460 -0
  22. package/dist/shared/hosted.js +8 -0
  23. package/dist/shared/ui.js +141 -0
  24. package/dist/skill/usebecky/SKILL.md +339 -0
  25. package/dist/skill/usebecky/references/access-rules.md +307 -0
  26. package/dist/skill/usebecky/references/addons.md +68 -0
  27. package/dist/skill/usebecky/references/analytics.md +166 -0
  28. package/dist/skill/usebecky/references/android.md +434 -0
  29. package/dist/skill/usebecky/references/auth.md +379 -0
  30. package/dist/skill/usebecky/references/cache.md +51 -0
  31. package/dist/skill/usebecky/references/components.md +127 -0
  32. package/dist/skill/usebecky/references/emails.md +105 -0
  33. package/dist/skill/usebecky/references/expo.md +147 -0
  34. package/dist/skill/usebecky/references/functions.md +99 -0
  35. package/dist/skill/usebecky/references/hosting.md +119 -0
  36. package/dist/skill/usebecky/references/http-api.md +233 -0
  37. package/dist/skill/usebecky/references/ios.md +355 -0
  38. package/dist/skill/usebecky/references/payments.md +493 -0
  39. package/dist/skill/usebecky/references/realtime.md +143 -0
  40. package/dist/skill/usebecky/references/scheduled-jobs.md +82 -0
  41. package/dist/skill/usebecky/references/sdk.md +838 -0
  42. package/dist/skill/usebecky/references/storage.md +210 -0
  43. package/dist/skill/usebecky/references/templates.md +191 -0
  44. package/dist/skill/usebecky/references/wordpress.md +87 -0
  45. package/dist/templates.js +74 -0
  46. package/package.json +37 -4
  47. package/templates/expo/App.tsx +48 -0
  48. package/templates/expo/README.md +59 -0
  49. package/templates/expo/_env.example +4 -0
  50. package/templates/expo/_gitignore +12 -0
  51. package/templates/expo/app.json +25 -0
  52. package/templates/expo/assets/icon.png +0 -0
  53. package/templates/expo/brand.ts +7 -0
  54. package/templates/expo/components/Avatar.tsx +75 -0
  55. package/templates/expo/components/ui.tsx +57 -0
  56. package/templates/expo/index.ts +4 -0
  57. package/templates/expo/lib/theme.ts +43 -0
  58. package/templates/expo/lib/usebecky.ts +15 -0
  59. package/templates/expo/package.json +29 -0
  60. package/templates/expo/screens/Home.tsx +187 -0
  61. package/templates/expo/screens/SignIn.tsx +112 -0
  62. package/templates/expo/tsconfig.json +6 -0
  63. package/templates/expo/usebecky.template.json +36 -0
  64. package/templates/extension/README.md +128 -0
  65. package/templates/extension/_env.example +21 -0
  66. package/templates/extension/_gitignore +11 -0
  67. package/templates/extension/logo.svg +1 -0
  68. package/templates/extension/package.json +25 -0
  69. package/templates/extension/src/accounts.ts +90 -0
  70. package/templates/extension/src/app.ts +178 -0
  71. package/templates/extension/src/pages.ts +108 -0
  72. package/templates/extension/src/replay-guard.ts +17 -0
  73. package/templates/extension/src/server.ts +57 -0
  74. package/templates/extension/src/settings.ts +69 -0
  75. package/templates/extension/src/ui.ts +70 -0
  76. package/templates/extension/test/app.test.ts +222 -0
  77. package/templates/extension/tsconfig.json +16 -0
  78. package/templates/extension/usebecky-extension.json +36 -0
  79. package/templates/extension/usebecky.template.json +22 -0
  80. package/templates/landing/README.md +43 -0
  81. package/templates/landing/_env.example +4 -0
  82. package/templates/landing/_gitignore +9 -0
  83. package/templates/landing/index.html +16 -0
  84. package/templates/landing/package.json +28 -0
  85. package/templates/landing/public/icon.svg +1 -0
  86. package/templates/landing/src/App.tsx +97 -0
  87. package/templates/landing/src/components/Contact.tsx +43 -0
  88. package/templates/landing/src/components/Counter.tsx +34 -0
  89. package/templates/landing/src/components/Feedback.tsx +36 -0
  90. package/templates/landing/src/components/Logo.tsx +11 -0
  91. package/templates/landing/src/components/Receipt.tsx +128 -0
  92. package/templates/landing/src/components/Setup.tsx +20 -0
  93. package/templates/landing/src/components/fields.tsx +63 -0
  94. package/templates/landing/src/content.ts +22 -0
  95. package/templates/landing/src/index.css +119 -0
  96. package/templates/landing/src/lib/usebecky.ts +11 -0
  97. package/templates/landing/src/lib/waitlist.ts +46 -0
  98. package/templates/landing/src/main.tsx +12 -0
  99. package/templates/landing/src/vite-env.d.ts +6 -0
  100. package/templates/landing/tsconfig.json +19 -0
  101. package/templates/landing/usebecky.template.json +20 -0
  102. package/templates/landing/vite.config.ts +10 -0
  103. package/templates/notes/README.md +68 -0
  104. package/templates/notes/_env.example +4 -0
  105. package/templates/notes/_gitignore +9 -0
  106. package/templates/notes/index.html +15 -0
  107. package/templates/notes/package.json +28 -0
  108. package/templates/notes/public/icon.svg +1 -0
  109. package/templates/notes/src/App.tsx +35 -0
  110. package/templates/notes/src/brand.ts +7 -0
  111. package/templates/notes/src/components/Composer.tsx +113 -0
  112. package/templates/notes/src/components/NoteEntry.tsx +151 -0
  113. package/templates/notes/src/components/Notes.tsx +163 -0
  114. package/templates/notes/src/components/Setup.tsx +44 -0
  115. package/templates/notes/src/components/SignIn.tsx +112 -0
  116. package/templates/notes/src/components/icons.tsx +54 -0
  117. package/templates/notes/src/index.css +105 -0
  118. package/templates/notes/src/lib/notes.ts +68 -0
  119. package/templates/notes/src/lib/usebecky.ts +9 -0
  120. package/templates/notes/src/main.tsx +22 -0
  121. package/templates/notes/src/vite-env.d.ts +6 -0
  122. package/templates/notes/tsconfig.json +19 -0
  123. package/templates/notes/usebecky.template.json +34 -0
  124. package/templates/notes/vite.config.ts +10 -0
  125. package/templates/saas/README.md +69 -0
  126. package/templates/saas/_env.example +10 -0
  127. package/templates/saas/_gitignore +11 -0
  128. package/templates/saas/app/(app)/account/ManageBilling.tsx +26 -0
  129. package/templates/saas/app/(app)/account/page.tsx +71 -0
  130. package/templates/saas/app/(app)/dashboard/Projects.tsx +227 -0
  131. package/templates/saas/app/(app)/dashboard/page.tsx +21 -0
  132. package/templates/saas/app/(app)/layout.tsx +29 -0
  133. package/templates/saas/app/(app)/premium/page.tsx +62 -0
  134. package/templates/saas/app/auth/callback/page.tsx +33 -0
  135. package/templates/saas/app/globals.css +143 -0
  136. package/templates/saas/app/icon.svg +1 -0
  137. package/templates/saas/app/layout.tsx +20 -0
  138. package/templates/saas/app/page.tsx +87 -0
  139. package/templates/saas/app/pricing/Plans.tsx +133 -0
  140. package/templates/saas/app/pricing/TestCardHint.tsx +18 -0
  141. package/templates/saas/app/pricing/page.tsx +21 -0
  142. package/templates/saas/app/setup/page.tsx +34 -0
  143. package/templates/saas/app/sign-in/SignInForm.tsx +195 -0
  144. package/templates/saas/app/sign-in/page.tsx +21 -0
  145. package/templates/saas/brand.ts +10 -0
  146. package/templates/saas/components/AppNav.tsx +45 -0
  147. package/templates/saas/components/Logo.tsx +22 -0
  148. package/templates/saas/components/SiteHeader.tsx +50 -0
  149. package/templates/saas/components/Status.tsx +15 -0
  150. package/templates/saas/lib/session.ts +26 -0
  151. package/templates/saas/lib/usebecky.ts +11 -0
  152. package/templates/saas/next-env.d.ts +5 -0
  153. package/templates/saas/next.config.ts +5 -0
  154. package/templates/saas/package.json +26 -0
  155. package/templates/saas/postcss.config.mjs +3 -0
  156. package/templates/saas/tsconfig.json +21 -0
  157. package/templates/saas/usebecky.template.json +31 -0
@@ -0,0 +1,195 @@
1
+ 'use client'
2
+ // Three ways in: Google, email + password, or a 6-digit code sent by email (no password needed).
3
+ import { useRouter } from 'next/navigation'
4
+ import { useEffect, useState, type FormEvent } from 'react'
5
+ import { baas } from '@/lib/usebecky'
6
+
7
+ type Mode = 'sign-in' | 'sign-up'
8
+ type Method = 'password' | 'code'
9
+
10
+ export function SignInForm({ next, initialMode }: { next: string; initialMode: Mode }) {
11
+ const router = useRouter()
12
+ const [mode, setMode] = useState<Mode>(initialMode)
13
+ const [method, setMethod] = useState<Method>('password')
14
+ const [email, setEmail] = useState('')
15
+ const [password, setPassword] = useState('')
16
+ const [code, setCode] = useState('')
17
+ const [codeSent, setCodeSent] = useState(false)
18
+ const [busy, setBusy] = useState(false)
19
+ const [message, setMessage] = useState<{ tone: 'error' | 'info'; text: string } | null>(null)
20
+
21
+ function done() {
22
+ // The session cookie is set now, so server pages can see who you are.
23
+ router.replace(next)
24
+ router.refresh()
25
+ }
26
+
27
+ // Already signed in (for example the cookie had expired)? This refreshes the session and moves on.
28
+ useEffect(() => {
29
+ baas.auth.getUser().then(({ data }) => {
30
+ if (data?.user) done()
31
+ })
32
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33
+ }, [])
34
+
35
+ const callback = () => `${window.location.origin}/auth/callback?next=${encodeURIComponent(next)}`
36
+
37
+ async function withPassword(event: FormEvent<HTMLFormElement>) {
38
+ event.preventDefault()
39
+ setBusy(true)
40
+ setMessage(null)
41
+ if (mode === 'sign-in') {
42
+ const { error } = await baas.auth.signIn({ email, password })
43
+ setBusy(false)
44
+ if (error) return setMessage({ tone: 'error', text: error.code === 'invalid_credentials' ? 'That email and password don’t match. Try again, or use an email code.' : error.message })
45
+ return done()
46
+ }
47
+ const { data, error } = await baas.auth.signUp({ email, password, redirectTo: callback() })
48
+ setBusy(false)
49
+ if (error) return setMessage({ tone: 'error', text: error.message })
50
+ if (!data.session) return setMessage({ tone: 'info', text: `Check ${email}: click the link in the email we sent, and you’re in.` })
51
+ done()
52
+ }
53
+
54
+ async function sendCode(event: FormEvent<HTMLFormElement>) {
55
+ event.preventDefault()
56
+ setBusy(true)
57
+ setMessage(null)
58
+ const { error } = await baas.auth.sendMagicLink(email, { createUser: true, redirectTo: callback() })
59
+ setBusy(false)
60
+ if (error) return setMessage({ tone: 'error', text: error.message })
61
+ setCodeSent(true)
62
+ setMessage({ tone: 'info', text: `We sent a 6-digit code to ${email}. It works for a few minutes.` })
63
+ }
64
+
65
+ async function verify(event: FormEvent<HTMLFormElement>) {
66
+ event.preventDefault()
67
+ setBusy(true)
68
+ setMessage(null)
69
+ const { error } = await baas.auth.verifyCode(email, code)
70
+ setBusy(false)
71
+ if (error) return setMessage({ tone: 'error', text: error.code === 'otp_expired' ? 'That code is wrong or has expired. Check the newest email, or send a new code.' : error.message })
72
+ done()
73
+ }
74
+
75
+ async function google() {
76
+ setMessage(null)
77
+ const settings = await baas.auth.settings()
78
+ if (settings.data && !settings.data.providers?.google) {
79
+ return setMessage({ tone: 'info', text: 'Google sign-in isn’t turned on for this app yet. Turn it on in Dashboard → Auth → Sign-in methods, or use your email below.' })
80
+ }
81
+ await baas.auth.signInWith('google', { redirectTo: callback() })
82
+ }
83
+
84
+ const signUp = mode === 'sign-up'
85
+
86
+ return (
87
+ <div>
88
+ <h1 className="headline text-[2.75rem]">{signUp ? 'Create your account' : 'Welcome back'}</h1>
89
+ <p className="mt-3 text-muted">{signUp ? 'Free to start. No card needed.' : 'Sign in to pick up where you left off.'}</p>
90
+
91
+ <button type="button" onClick={google} className="btn btn-ghost mt-8 h-12 w-full">
92
+ <GoogleIcon />
93
+ Continue with Google
94
+ </button>
95
+
96
+ <div className="my-6 flex items-center gap-3 text-sm text-muted" aria-hidden="true">
97
+ <span className="h-px flex-1 bg-line" />
98
+ or with your email
99
+ <span className="h-px flex-1 bg-line" />
100
+ </div>
101
+
102
+ <div role="tablist" aria-label="How to sign in" className="mb-5 grid grid-cols-2 rounded-xl bg-sunken p-1 text-sm font-semibold">
103
+ {(['password', 'code'] as const).map((m) => (
104
+ <button
105
+ key={m}
106
+ role="tab"
107
+ type="button"
108
+ aria-selected={method === m}
109
+ onClick={() => {
110
+ setMethod(m)
111
+ setMessage(null)
112
+ }}
113
+ className={`h-9 rounded-lg transition-colors ${method === m ? 'bg-surface text-ink shadow-sm' : 'text-muted hover:text-ink'}`}
114
+ >
115
+ {m === 'password' ? 'Password' : 'Email me a code'}
116
+ </button>
117
+ ))}
118
+ </div>
119
+
120
+ {method === 'password' ? (
121
+ <form onSubmit={withPassword} className="space-y-4">
122
+ <Field id="email" label="Email" type="email" autoComplete="email" value={email} onChange={setEmail} />
123
+ <Field id="password" label="Password" type="password" autoComplete={signUp ? 'new-password' : 'current-password'} value={password} onChange={setPassword} minLength={6} hint={signUp ? 'At least 6 characters' : undefined} />
124
+ <button type="submit" disabled={busy} className="btn btn-primary h-12 w-full">
125
+ {busy ? 'One moment…' : signUp ? 'Create account' : 'Sign in'}
126
+ </button>
127
+ </form>
128
+ ) : !codeSent ? (
129
+ <form onSubmit={sendCode} className="space-y-4">
130
+ <Field id="code-email" label="Email" type="email" autoComplete="email" value={email} onChange={setEmail} />
131
+ <button type="submit" disabled={busy} className="btn btn-primary h-12 w-full">
132
+ {busy ? 'Sending…' : 'Send me a code'}
133
+ </button>
134
+ </form>
135
+ ) : (
136
+ <form onSubmit={verify} className="space-y-4">
137
+ <Field id="code" label="6-digit code" type="text" inputMode="numeric" autoComplete="one-time-code" value={code} onChange={(v) => setCode(v.replace(/\D/g, '').slice(0, 6))} pattern="\d{6}" />
138
+ <button type="submit" disabled={busy || code.length !== 6} className="btn btn-primary h-12 w-full">
139
+ {busy ? 'Checking…' : 'Sign in'}
140
+ </button>
141
+ <button type="button" onClick={() => (setCodeSent(false), setCode(''), setMessage(null))} className="w-full text-sm font-medium text-muted hover:text-ink">
142
+ Use a different email
143
+ </button>
144
+ </form>
145
+ )}
146
+
147
+ {message && (
148
+ <p role={message.tone === 'error' ? 'alert' : 'status'} className={`mt-5 rounded-xl px-4 py-3 text-sm leading-relaxed ${message.tone === 'error' ? 'bg-danger/10 text-danger' : 'bg-accent-soft'}`}>
149
+ {message.text}
150
+ </p>
151
+ )}
152
+
153
+ <p className="mt-8 text-sm text-muted">
154
+ {signUp ? 'Already have an account?' : 'New here?'}{' '}
155
+ <button type="button" onClick={() => (setMode(signUp ? 'sign-in' : 'sign-up'), setMessage(null))} className="font-semibold text-accent hover:underline">
156
+ {signUp ? 'Sign in' : 'Create an account'}
157
+ </button>
158
+ </p>
159
+ </div>
160
+ )
161
+ }
162
+
163
+ function Field(props: { id: string; label: string; type: string; value: string; onChange: (v: string) => void; autoComplete: string; hint?: string; minLength?: number; inputMode?: 'numeric'; pattern?: string }) {
164
+ return (
165
+ <div>
166
+ <label htmlFor={props.id} className="mb-1.5 flex justify-between text-sm font-semibold">
167
+ {props.label}
168
+ {props.hint && <span className="font-normal text-muted">{props.hint}</span>}
169
+ </label>
170
+ <input
171
+ id={props.id}
172
+ className="input h-12"
173
+ type={props.type}
174
+ required
175
+ value={props.value}
176
+ onChange={(e) => props.onChange(e.target.value)}
177
+ autoComplete={props.autoComplete}
178
+ minLength={props.minLength}
179
+ inputMode={props.inputMode}
180
+ pattern={props.pattern}
181
+ />
182
+ </div>
183
+ )
184
+ }
185
+
186
+ function GoogleIcon() {
187
+ return (
188
+ <svg width="18" height="18" viewBox="0 0 48 48" aria-hidden="true">
189
+ <path fill="#FFC107" d="M43.6 20.5H42V20H24v8h11.3C33.7 32.7 29.2 36 24 36c-6.6 0-12-5.4-12-12s5.4-12 12-12c3.1 0 5.8 1.2 7.9 3.1l5.7-5.7C34 6.1 29.3 4 24 4 12.9 4 4 12.9 4 24s8.9 20 20 20 20-8.9 20-20c0-1.3-.1-2.4-.4-3.5z" />
190
+ <path fill="#FF3D00" d="m6.3 14.7 6.6 4.8C14.7 15.1 19 12 24 12c3.1 0 5.8 1.2 7.9 3.1l5.7-5.7C34 6.1 29.3 4 24 4 16.3 4 9.7 8.3 6.3 14.7z" />
191
+ <path fill="#4CAF50" d="M24 44c5.2 0 9.9-2 13.4-5.2l-6.2-5.2C29.2 35.1 26.7 36 24 36c-5.2 0-9.6-3.3-11.3-8l-6.5 5C9.5 39.6 16.2 44 24 44z" />
192
+ <path fill="#1976D2" d="M43.6 20.5H42V20H24v8h11.3c-.8 2.2-2.2 4.2-4.1 5.6l6.2 5.2C37 39.2 44 34 44 24c0-1.3-.1-2.4-.4-3.5z" />
193
+ </svg>
194
+ )
195
+ }
@@ -0,0 +1,21 @@
1
+ import { redirect } from 'next/navigation'
2
+ import { Logo } from '@/components/Logo'
3
+ import { configured } from '@/lib/session'
4
+ import { SignInForm } from './SignInForm'
5
+
6
+ export const metadata = { title: 'Sign in' }
7
+
8
+ export default async function SignInPage({ searchParams }: { searchParams: Promise<{ next?: string; mode?: string }> }) {
9
+ if (!configured) redirect('/setup')
10
+ const params = await searchParams
11
+ // Only send people back to pages on this site.
12
+ const next = params.next?.startsWith('/') && !params.next.startsWith('//') ? params.next : '/dashboard'
13
+ return (
14
+ <main className="flex min-h-dvh flex-col px-5 py-6 sm:px-8">
15
+ <Logo />
16
+ <div className="mx-auto flex w-full max-w-[25rem] flex-1 flex-col justify-center py-12">
17
+ <SignInForm next={next} initialMode={params.mode === 'sign-up' ? 'sign-up' : 'sign-in'} />
18
+ </div>
19
+ </main>
20
+ )
21
+ }
@@ -0,0 +1,10 @@
1
+ // Your product's name and the words around it. Change them here and they change everywhere.
2
+ // The colour lives in app/globals.css (--brand).
3
+ export const brand = {
4
+ name: 'Plotline',
5
+ tagline: 'Every project, from first sketch to shipped.',
6
+ description: 'Plotline keeps your projects, their status and the next step in one calm list, so nothing slips between tools.',
7
+ /** Shown on the pricing page. The prices themselves come from Dashboard → Payments. */
8
+ proFeatures: ['Everything in Free', 'Premium-only guides and templates', 'Priority email support', 'Cancel any time from your account'],
9
+ freeFeatures: ['Unlimited projects', 'Sign in with email, a code or Google', 'Your data private to you'],
10
+ }
@@ -0,0 +1,45 @@
1
+ 'use client'
2
+ import Link from 'next/link'
3
+ import { usePathname, useRouter } from 'next/navigation'
4
+ import { baas } from '@/lib/usebecky'
5
+
6
+ const LINKS = [
7
+ { href: '/dashboard', label: 'Projects' },
8
+ { href: '/premium', label: 'Premium guides' },
9
+ { href: '/account', label: 'Account' },
10
+ ]
11
+
12
+ export function AppNav() {
13
+ const pathname = usePathname()
14
+ return (
15
+ <nav aria-label="App" className="flex gap-1 lg:flex-col">
16
+ {LINKS.map((l) => {
17
+ const active = pathname === l.href
18
+ return (
19
+ <Link
20
+ key={l.href}
21
+ href={l.href}
22
+ aria-current={active ? 'page' : undefined}
23
+ className={`rounded-lg px-3 py-2 text-[0.95rem] font-medium transition-colors ${active ? 'bg-surface text-ink shadow-[0_1px_2px_rgb(0_0_0/0.06)] ring-1 ring-line' : 'text-muted hover:text-ink'}`}
24
+ >
25
+ {l.label}
26
+ </Link>
27
+ )
28
+ })}
29
+ </nav>
30
+ )
31
+ }
32
+
33
+ export function SignOutButton({ className = '' }: { className?: string }) {
34
+ const router = useRouter()
35
+ async function signOut() {
36
+ await baas.auth.signOut() // also clears the cookie
37
+ router.replace('/sign-in')
38
+ router.refresh()
39
+ }
40
+ return (
41
+ <button onClick={signOut} className={`text-sm font-medium text-muted hover:text-ink ${className}`}>
42
+ Sign out
43
+ </button>
44
+ )
45
+ }
@@ -0,0 +1,22 @@
1
+ import Link from 'next/link'
2
+ import { brand } from '@/brand'
3
+
4
+ /** The mark: a plot line climbing to a point. Uses the brand colour. */
5
+ export function Mark({ size = 28 }: { size?: number }) {
6
+ return (
7
+ <svg width={size} height={size} viewBox="0 0 32 32" aria-hidden="true">
8
+ <rect width="32" height="32" rx="9" fill="var(--accent)" />
9
+ <path d="M7 22.5 13 16l4.5 3.5L25 10" fill="none" stroke="var(--accent-ink)" strokeWidth="2.6" strokeLinecap="round" strokeLinejoin="round" />
10
+ <circle cx="25" cy="10" r="2.6" fill="var(--accent-ink)" />
11
+ </svg>
12
+ )
13
+ }
14
+
15
+ export function Logo({ href = '/' }: { href?: string }) {
16
+ return (
17
+ <Link href={href} className="flex items-center gap-2.5 text-[1.1rem] font-bold tracking-[-0.02em]">
18
+ <Mark />
19
+ {brand.name}
20
+ </Link>
21
+ )
22
+ }
@@ -0,0 +1,50 @@
1
+ // The header on the public pages. Shows "Dashboard" when you're signed in (checked on the server).
2
+ import Link from 'next/link'
3
+ import { getUser } from '@/lib/session'
4
+ import { Logo } from './Logo'
5
+
6
+ export async function SiteHeader() {
7
+ const user = await getUser()
8
+ return (
9
+ <header className="mx-auto flex h-18 max-w-6xl items-center justify-between gap-4 px-5 sm:px-8">
10
+ <Logo />
11
+ <nav className="flex items-center gap-1 text-[0.95rem] font-medium sm:gap-2" aria-label="Main">
12
+ <Link href="/pricing" className="rounded-lg px-3 py-2 text-muted transition-colors hover:text-ink">
13
+ Pricing
14
+ </Link>
15
+ {user ? (
16
+ <Link href="/dashboard" className="btn btn-primary h-10">
17
+ Dashboard
18
+ </Link>
19
+ ) : (
20
+ <>
21
+ <Link href="/sign-in" className="hidden rounded-lg px-3 py-2 text-muted transition-colors hover:text-ink sm:block">
22
+ Sign in
23
+ </Link>
24
+ <Link href="/sign-in?mode=sign-up" className="btn btn-primary h-10">
25
+ Start free
26
+ </Link>
27
+ </>
28
+ )}
29
+ </nav>
30
+ </header>
31
+ )
32
+ }
33
+
34
+ export function SiteFooter() {
35
+ return (
36
+ <footer className="border-t border-line">
37
+ <div className="mx-auto flex max-w-6xl flex-wrap items-center justify-between gap-4 px-5 py-8 text-sm text-muted sm:px-8">
38
+ <Logo />
39
+ <nav className="flex gap-5" aria-label="Footer">
40
+ <Link href="/pricing" className="hover:text-ink">
41
+ Pricing
42
+ </Link>
43
+ <Link href="/sign-in" className="hover:text-ink">
44
+ Sign in
45
+ </Link>
46
+ </nav>
47
+ </div>
48
+ </footer>
49
+ )
50
+ }
@@ -0,0 +1,15 @@
1
+ // Project statuses. Add your own here: the "status" column is plain text.
2
+ export const STATUSES = [
3
+ { value: 'active', label: 'In progress' },
4
+ { value: 'paused', label: 'On hold' },
5
+ { value: 'done', label: 'Shipped' },
6
+ ] as const
7
+
8
+ export function statusLabel(value: string) {
9
+ return STATUSES.find((s) => s.value === value)?.label ?? value
10
+ }
11
+
12
+ export function StatusDot({ status }: { status: string }) {
13
+ const color = status === 'done' ? 'bg-good' : status === 'paused' ? 'bg-muted/60' : 'bg-accent'
14
+ return <span className={`inline-block size-2 shrink-0 rounded-full ${color}`} aria-hidden="true" />
15
+ }
@@ -0,0 +1,26 @@
1
+ // Server-side helpers: who is signed in? Uses usebecky/server, which checks the "ub-access-token"
2
+ // cookie with usebecky (results are cached for about 30 seconds).
3
+ import { cookies } from 'next/headers'
4
+ import { redirect } from 'next/navigation'
5
+ import { baas } from 'usebecky/server'
6
+
7
+ /** False until .env.local has your project's keys (then /setup explains what to do). */
8
+ export const configured = Boolean(process.env.NEXT_PUBLIC_USEBECKY_PUBLISHABLE_KEY && process.env.USEBECKY_SECRET_KEY)
9
+
10
+ /** The signed-in user, or null. */
11
+ export async function getUser() {
12
+ if (!configured) return null
13
+ return baas.auth.getUser(await cookies())
14
+ }
15
+
16
+ /**
17
+ * For pages only signed-in people may see. Sends everyone else to the sign-in page, which brings
18
+ * them back here afterwards. Returns the user and `db`, the database AS this user (access rules apply).
19
+ */
20
+ export async function requireUser(path: string) {
21
+ if (!configured) redirect('/setup')
22
+ const cookieStore = await cookies()
23
+ const user = await baas.auth.getUser(cookieStore)
24
+ if (!user) redirect(`/sign-in?next=${encodeURIComponent(path)}`)
25
+ return { user, db: baas.as(cookieStore) }
26
+ }
@@ -0,0 +1,11 @@
1
+ // Your usebecky client for browser code ('use client' components).
2
+ // In server code (server components, route handlers, server actions) use: import { baas } from 'usebecky/server'
3
+ // It also copies the access token into a "ub-access-token" cookie, which is how the server knows who is signed in.
4
+ import { createClient } from 'usebecky'
5
+
6
+ export const baas = createClient(
7
+ // Without a URL the client uses the hosted API. The key fallback only matters before .env.local exists:
8
+ // the app then shows /setup instead of crashing.
9
+ process.env.NEXT_PUBLIC_USEBECKY_URL,
10
+ process.env.NEXT_PUBLIC_USEBECKY_PUBLISHABLE_KEY || 'ub_pk_notconfigured_0',
11
+ )
@@ -0,0 +1,5 @@
1
+ /// <reference types="next" />
2
+ /// <reference types="next/image-types/global" />
3
+
4
+ // NOTE: This file should not be edited
5
+ // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
@@ -0,0 +1,5 @@
1
+ import type { NextConfig } from 'next'
2
+
3
+ const nextConfig: NextConfig = {}
4
+
5
+ export default nextConfig
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "plotline",
3
+ "private": true,
4
+ "version": "0.1.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "next dev",
8
+ "build": "next build",
9
+ "start": "next start",
10
+ "typecheck": "tsc --noEmit"
11
+ },
12
+ "dependencies": {
13
+ "next": "16.4.3",
14
+ "react": "19.3.1",
15
+ "react-dom": "19.3.1",
16
+ "usebecky": "^0.2.0"
17
+ },
18
+ "devDependencies": {
19
+ "@tailwindcss/postcss": "4.3.3",
20
+ "@types/node": "26.6.6",
21
+ "@types/react": "19.3.0",
22
+ "@types/react-dom": "19.3.0",
23
+ "tailwindcss": "4.3.3",
24
+ "typescript": "5.9.3"
25
+ }
26
+ }
@@ -0,0 +1,3 @@
1
+ export default {
2
+ plugins: { '@tailwindcss/postcss': {} },
3
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": false,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "noEmit": true,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "bundler",
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "jsx": "react-jsx",
15
+ "incremental": true,
16
+ "plugins": [{ "name": "next" }],
17
+ "paths": { "@/*": ["./*"] }
18
+ },
19
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", ".next/dev/types/**/*.ts"],
20
+ "exclude": ["node_modules"]
21
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "id": "saas",
3
+ "name": "SaaS",
4
+ "description": "Sign-in, projects, Stripe plans, a Premium page",
5
+ "stack": "Next.js",
6
+ "kind": "node",
7
+ "framework": "next",
8
+ "serverTemplate": "saas",
9
+ "order": 2,
10
+ "brandName": "Plotline",
11
+ "brandSlug": "plotline",
12
+ "brandFiles": ["brand.ts"],
13
+ "customize": { "name": "brand.ts", "colour": "app/globals.css (--brand)" },
14
+ "requires": { "tables": ["projects", "premium_content", "profiles"] },
15
+ "setup": {
16
+ "tables": [
17
+ {
18
+ "name": "projects",
19
+ "preset": "owner",
20
+ "comment": "Each user sees only their own projects.",
21
+ "columns": [
22
+ { "name": "name", "type": "text", "nullable": false },
23
+ { "name": "description", "type": "text" },
24
+ { "name": "status", "type": "text", "nullable": false, "default": "'active'" }
25
+ ]
26
+ }
27
+ ]
28
+ },
29
+ "run": { "script": "dev", "url": "http://localhost:3000", "port": 3000 },
30
+ "docs": [{ "title": "Next.js guide", "path": "frameworks/nextjs" }]
31
+ }