JavaScript SDK

create-scute-app

A CLI that installs the Scute packages, adds the app ID to the env file and writes the sign-in files for your framework.

create-scute-app adds Scute sign-in to the project in the current folder. It writes the same files, packages and env line that the dashboard's code snippets show. This page describes version 0.3.0-next.0.

Run it#

Run it from the project's root, next to package.json:

npx create-scute-app@next --framework nextjs --app-id YOUR_APP_ID

Without flags it detects the framework and asks for the app ID.

FlagValue
--frameworknextjs, react, javascript, node, astro, remix or tanstack
--app-idThe app ID from the app's page in the dashboard
--no-installSkip the install and print the command instead
--help, -hPrint usage

What it does#

  1. Detects the framework from package.json dependencies (next, astro, @remix-run/react or @react-router/dev, @tanstack/react-start, react, vite, in that order), then from config files.
  2. Installs the recipe's packages with the project's package manager: packageManager in package.json, else the lockfile (pnpm-lock.yaml, yarn.lock, bun.lock), else npm.
  3. Adds the app ID line to the env file. An existing value for the same variable is left as is.
  4. Writes the recipe's files. A file that already exists is left as is, and the CLI prints the Scute version for you to merge. Paths under src/ drop the src/ when the project has no src folder.

It never asks for the secret key and never writes it.

Recipes#

FrameworkPackagesEnv lineFiles
Next.js@scute/nextjs-handlers, @scute/react-hooks, @scute/auth-ui-react.env.local: NEXT_PUBLIC_SCUTE_APP_IDsrc/app/auth/[...scute]/route.ts, src/app/scute-providers.tsx
React@scute/react-hooks, @scute/auth-ui-react.env: VITE_SCUTE_APP_IDsrc/scute-providers.tsx
JavaScript@scute/js-core.env: VITE_SCUTE_APP_IDsrc/sign-in.js
Node@scute/js-core.env: SCUTE_APP_IDscute-auth.js
Astro@scute/react-hooks, @scute/auth-ui-react.env: PUBLIC_SCUTE_APP_IDsrc/components/ScuteAuth.tsx
Remix@scute/react-hooks, @scute/auth-ui-react.env: VITE_SCUTE_APP_IDapp/scute-providers.tsx
TanStack Start@scute/react-hooks, @scute/auth-ui-react.env: VITE_SCUTE_APP_IDsrc/scute-providers.tsx

Only @scute/nextjs-handlers reads its env variable itself. In the other recipes the code passes the value to createClient.

After the files are in, the CLI prints the one step left, for example "Wrap the root layout's children in ScuteProviders" for Next.js.

Recipes as a module#

The recipes are exported for your own tooling:

import { sdkRecipe, sdkRecipes, FRAMEWORKS } from "create-scute-app/recipes";const recipe = sdkRecipe("react", "YOUR_APP_ID");console.log(recipe.install); // npm install @scute/react-hooks @scute/auth-ui-reactfor (const file of recipe.files) console.log(file.path);

sdkRecipe(id, appId, signIn?) returns { id, label, language, filename, code, files, packages, install, envFile, env, envNote, then, docs }. The optional signIn argument (appearance, copy, legal, methods) writes those ScuteSignIn props into the generated ScuteAuthGate; only values that differ from the defaults are written.