Website · Documentation · Connectors · Create a free test account
GitHub sign-in that works the moment you run pnpm dev, with no GitHub OAuth app. A Svelte CLI community add-on that sets up Better Auth with a GitHub demo, and signs in through Mockatoo's free hosted GitHub mock in development.
npx sv add @mockatooImportant
Svelte maintainers have not reviewed community add-ons for malicious code. The CLI says so and asks before it runs this one. The source is all in src/index.js.
It only sets up new auth. It never edits an auth setup you already have.
| Your project | What happens |
|---|---|
No auth yet (a new sv create app, or an existing app without auth) |
Adds Better Auth with its GitHub demo (and Drizzle, if you have no database), then makes the GitHub demo sign in through Mockatoo in development. |
Already has auth: Better Auth, Auth.js, Lucia, Arctic, Supabase, Clerk, Kinde, WorkOS, or a src/lib/server/auth.(ts|js) file |
Changes nothing. It stops with a message pointing to the Mockatoo skill and the matching example (see Already have auth?). |
| Not SvelteKit | Changes nothing. The add-on requires SvelteKit 2 or 3; CI tests both. |
On a project with no auth, npx sv add @mockatoo:
-
Adds Better Auth with the GitHub demo through the official
better-authadd-on, as if you'd runnpx sv add better-auth="demo:github". You get its usual files:src/lib/server/auth.ts, the demo at/demo/better-auth, and.enventries. If the project has no database, the official add-on also adds Drizzle and asks which database to use. -
Gates GitHub on SvelteKit's
devinsrc/lib/server/auth.ts:+ import { dev } from '$app/env'; // '$app/environment' on SvelteKit 2 + import { mockGitHub } from '@mockatoo/connect-better-auth'; ... - socialProviders: { + socialProviders: dev + ? {} + : { github: { clientId: GITHUB_CLIENT_ID, clientSecret: GITHUB_CLIENT_SECRET } }, plugins: [ + ...(dev ? [mockGitHub()] : []), sveltekitCookies(getRequestEvent) ]
-
Adds
@mockatoo/connect-better-auth, a Better Auth plugin that registers Mockatoo's GitHub mock under the provider idgithub. The demo's "Sign in with GitHub" button andauth.api.signInSocial({ provider: 'github' })work unchanged. -
On SvelteKit 3, adds
{ external: true }to the demo's sign-in redirect, because the mock is on another origin.
If auth.ts isn't in the shape the official add-on generates (for example, you chose a demo without GitHub in the same command), it stops and changes nothing in it.
Production is unchanged. dev is false in production builds, so they use the real GitHub provider with GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET, and the mock plugin isn't added.
npx sv create my-app --template minimal --types ts
cd my-app
npx sv add @mockatoo
pnpm auth:schema && pnpm db:push # create the auth tables
pnpm devOpen /demo/better-auth/login and click Sign in with GitHub. You land on Mockatoo's login page: sign in with a free Mockatoo account, click Authorize, and you're back in the app, signed in as a GitHub user.
The mock behaves like GitHub's OAuth, so a Playwright test can run the whole flow without bot checks or real accounts. Store your Mockatoo test account in MOCKATOO_TEST_EMAIL and MOCKATOO_TEST_PASSWORD, then:
await page.goto('/demo/better-auth/login');
await page.getByRole('button', { name: 'Sign in with GitHub' }).click();
await page.locator('#email').fill(process.env.MOCKATOO_TEST_EMAIL!);
await page.locator('#password').fill(process.env.MOCKATOO_TEST_PASSWORD!);
await page.getByRole('button', { name: 'Log in with password' }).click();
await page.getByRole('button', { name: 'Authorize' }).click();
await expect(page.locator('h1')).toContainText('Hi,');The dev server must use the same host as ORIGIN in .env, such as 127.0.0.1 for both, or Better Auth rejects the state cookie. See the Playwright guide and the CI guide.
The add-on won't edit an existing auth setup: auth code varies too much for a blind edit to be safe. Instead, let your coding agent add Mockatoo to the code you have:
npx skills add mockatoo/connectors --skill mockatooThen ask it to add Mockatoo for development and tests. Working examples:
- Better Auth + SvelteKit
- Auth.js + SvelteKit
- All examples (Next.js, Nuxt, Remix, Hono, Flask, Django, Laravel, Spring Boot)
None. Run it without arguments: npx sv add @mockatoo. It installs as @mockatoo or @mockatoo/sv, and npx sv add @mockatoo/sv@0.1.0 pins a version.
pnpm install
pnpm typecheck
pnpm test # refusal tests, plus a generated app on each SvelteKit variant
pnpm cli:check # the real CLI on SvelteKit 3 and 2: `sv create` + `sv add file:.`, type check, build, refusalpnpm test signs in to the hosted mock when MOCKATOO_TEST_EMAIL and MOCKATOO_TEST_PASSWORD are set. Without them, it checks the redirect to Mockatoo's login page and skips the full sign-in with a notice. To try it by hand: pnpm demo-create, then pnpm demo-add.
Bump version in package.json, then push a matching tag (v0.1.1). release.yml re-runs every check, including the full sign-in, and publishes to npm with trusted publishing: no npm token, and the package gets a provenance attestation. A prerelease version (0.2.0-beta.1) publishes under the next tag.
MIT. Mockatoo is free; the hosted service is at app.mockatoo.globalunderdog.com.