Documentation
Configuration
Where Motoko Base config files live and how to change navigation, billing plans, metadata, and integrations.
Motoko Base keeps product configuration in TypeScript files, not scattered across components. Environment variables (see Environment Variables) control secrets and external services; config files control labels, navigation, limits, and marketing content.
Configuration map
| Location | What it controls |
|---|---|
src/features/dashboard/config/ | Dashboard and settings navigation (nav.ts, settings-nav.ts) |
src/features/marketing/marketing-structure.ts | Landing page structure — section IDs, hrefs, ordering |
src/lib/billing/config/plans.ts | In-app billing plan labels and feature lists |
src/lib/billing/config.ts | Billing provider, plan IDs, feature gating |
src/lib/auth/auth.ts | Better Auth setup (email/password, OAuth, verification) |
src/app/layout.tsx | Root site metadata (title template, Open Graph) |
src/features/*/config.ts | Per-feature limits and options |
src/lib/*/config.ts | Integration helpers (analytics, monitoring, email) |
Dashboard navigation
Dashboard sidebar items live in src/features/dashboard/config/nav.ts. Add, remove, or reorder entries in dashboardNavGroups and settingsNavGroups:
export const dashboardNavGroups: DashboardNavGroup[] = [
{
items: [
{
title: "Overview",
href: "/dashboard",
icon: IconLayoutDashboard,
},
],
},
{
heading: "Demos",
items: [
{
title: "AI Email",
href: "/dashboard/ai-email",
icon: IconSparkles,
},
// add your feature here
],
},
];Each item needs a title, href, and Tabler icon. The shell reads this file for the sidebar title, active state, and settings sub-navigation.
To add a new dashboard page:
- Create the route under
src/app/dashboard/... - Add a nav item in
nav.ts(andsettings-nav.tsfor settings) - Build the UI in
src/features/<name>/
Marketing site
Landing page structure (section IDs, hrefs, tech refs, ordering) lives in src/features/marketing/marketing-structure.ts. Translatable copy lives in messages/{locale}/marketing.json. Section components merge both via useMarketingContent().
Do not put headlines, FAQ text, or footer labels in TypeScript config files — keep those in message catalogs. See Adding translations for the marketing pattern.
Key structure exports:
| Export | Used by |
|---|---|
marketingNavStructure | Header navigation links |
marketingFeatureStructure | Features catalogue layout |
marketingPricingStructure | Pricing section layout |
marketingFaqStructure | FAQ accordion layout |
marketingFooterStructure | Footer groups and social links |
Example — add a nav item in structure, then add the label in every locale's marketing.json:
// src/features/marketing/marketing-structure.ts
export const marketingNavStructure = [
{ id: "docs", href: "/docs" },
{ id: "changelog", href: "/changelog" },
] as const;// messages/en/marketing.json
{
"nav": {
"docs": "Documentation",
"changelog": "Changelog"
}
}Billing plans
Motoko Base has two layers of billing configuration:
In-app plan display
src/lib/billing/config/plans.ts defines how Free and Pro appear on the billing dashboard:
export const billingMarketing = {
free: {
name: "Free",
priceLabel: "$0",
periodLabel: "forever",
features: ["Core dashboard access", "Demo features for evaluation"],
},
pro: {
name: "Pro",
priceLabel: "$19",
periodLabel: "month",
features: ["Unlimited links", "100 GB storage", "AI generation", "Analytics"],
},
} as const;Update names, prices, and feature bullet points here. Checkout itself is handled by Polar — product IDs and tokens come from environment variables.
Plan logic and feature gating
src/lib/billing/config.ts controls provider selection, paid plan IDs, and which features require Pro:
export const billingConfig = {
provider: "polar",
paidPlans: ["pro"],
featurePlans: {
ai: "pro",
analytics: "pro",
storage: "pro",
links: "pro",
},
successPath: "/dashboard/settings/administration/billing?checkout=success",
returnPath: "/dashboard/billing",
} as const;Wire new feature gates through canAccess() in src/lib/billing/. Polar product setup (POLAR_PRO_MONTHLY_PRODUCT_ID, webhooks) is documented in Environment Variables.
Site metadata
Next.js metadata exports control SEO titles and Open Graph tags.
Root defaults — src/app/layout.tsx:
export const metadata: Metadata = {
title: {
default: "Motoko Base",
template: "%s · Motoko Base",
},
description: "Production-ready Next.js SaaS starter — auth, database, billing, email, and removable demo features.",
openGraph: {
title: "Motoko Base",
description: "...",
type: "website",
},
};The template suffix applies to pages that set their own title. Override metadata per route — for example, the landing page in src/app/(marketing)/(site)/page.tsx.
Email brand name — update brandName in src/lib/email/templates/shared.tsx so verification and password-reset emails match your product.
Authentication
Auth is configured in src/lib/auth/auth.ts using Better Auth. Email/password with required verification is enabled by default. Google and GitHub OAuth are included but only activate when GOOGLE_* and GITHUB_* env vars are set.
To customize auth behavior (verification emails, welcome emails, password reset), edit the callbacks in auth.ts:
export const auth = betterAuth({
baseURL,
emailAndPassword: {
enabled: true,
requireEmailVerification: true,
sendResetPassword: async ({ user, url }) => { /* ... */ },
},
emailVerification: {
sendOnSignUp: true,
sendVerificationEmail: async ({ user, url }) => { /* ... */ },
},
socialProviders: { /* google, github when configured */ },
});Social provider helpers live in src/lib/auth/social.ts. Do not put OAuth secrets in config files — they belong in environment variables.
Feature and integration config
Each feature and integration has a small config file for limits and defaults. Edit these instead of hard-coding values in components or server actions.
| File | Controls |
|---|---|
src/features/storage/config.ts | Max upload size, allowed MIME types, pagination |
src/features/ai-email/config.ts | Tone/length/language options, max email length, default model |
src/features/dashboard/config/preferences.ts | Theme and language options |
src/features/dashboard/config/notifications.ts | Notification defaults |
src/features/dashboard/lib/avatar.ts | Avatar size and MIME limits |
src/features/links/config.ts | Link list pagination |
src/lib/analytics/config.ts | PostHog host defaults and enable checks |
src/lib/monitoring/config.ts | Sentry enable rules and trace sampling |
src/lib/email/config.ts | Resend env readers |
Example — raise the storage upload limit:
// src/features/storage/config.ts
export const MAX_FILE_SIZE_BYTES = 25 * 1024 * 1024; // 25 MiBExample — add an AI tone option:
// src/features/ai-email/config.ts
export const TONE_OPTIONS = [
{ value: "professional", label: "Professional" },
{ value: "casual", label: "Casual" },
] as const;Server Zod schemas import these values — keep config files as the single source of truth.
Documentation navigation
Docs sidebar is driven by meta.json files under content/docs/. To add a page:
- Create an MDX file in the appropriate folder
- List it in that folder's
meta.json - Add a new folder to
content/docs/meta.jsonif you create a new section
Fumadocs compiles MDX on pnpm install and serves pages at /docs.
Rules of thumb
- Secrets in env, product choices in config — API keys and DSNs never belong in TypeScript config files
- Soft-fail optional integrations — unset env vars should disable a feature, not crash the app
- One source of truth — limits and option lists live in
config.ts; actions and UI import them - Copy a demo feature — when adding a new area, duplicate a
src/features/folder and wire it intonav.ts(andsettings-nav.tsfor settings)
For folder layout and where to put new code, see Project structure.
Next steps
Environment Variables — Full reference for .env variables.
Installation — First-run setup if you have not configured the project yet.