The SDK has packages for React and Next.js only. Every other framework uses @scute/js-core directly, or the React packages where the framework renders React.
Remix, React Router and TanStack Start#
These use the React provider from the React quickstart. Install @scute/react-hooks@next @scute/auth-ui-react@next, set VITE_SCUTE_APP_ID, then wrap the root:
| Framework | Provider file | Wrap |
|---|---|---|
| Remix (and React Router framework mode) | app/scute-providers.tsx | <Outlet /> in app/root.tsx |
| TanStack Start | src/scute-providers.tsx | The root route's children in src/routes/__root.tsx |
import { useState, type ReactNode } from "react";import { AuthContextProvider, createClient } from "@scute/react-hooks";import { ScuteAuthGate } from "@scute/auth-ui-react";export function ScuteProviders({ children }: { children: ReactNode }) { const [scute] = useState(() => createClient({ appId: import.meta.env.VITE_SCUTE_APP_ID })); return ( <AuthContextProvider scuteClient={scute}> <ScuteAuthGate>{children}</ScuteAuthGate> </AuthContextProvider> );}Astro#
Use a React island. It needs Astro's React integration (npx astro add react).
import type { ReactNode } from "react";import { AuthContextProvider, createClient } from "@scute/react-hooks";import { ScuteAuthGate } from "@scute/auth-ui-react";const scute = createClient({ appId: import.meta.env.PUBLIC_SCUTE_APP_ID });export default function ScuteAuth({ children }: { children?: ReactNode }) { return ( <AuthContextProvider scuteClient={scute}> <ScuteAuthGate>{children}</ScuteAuthGate> </AuthContextProvider> );}Put the pages that need sign-in inside <ScuteAuth client:only="react">.
React Native and Expo#
Install @scute/react-hooks@next, create the client and wrap the root layout in AuthContextProvider. useAuth and useScuteClient work as on the web; @scute/auth-ui-react renders DOM elements and does not run in React Native.
import { createClient } from "@scute/react-hooks";export const scuteClient = createClient({ appId: process.env.EXPO_PUBLIC_SCUTE_APP_ID! });Things that differ outside a browser:
- Passkeys are not offered: the WebAuthn browser API is missing, so signInOrUp falls back to a link or a code.
- Session storage is in memory unless you pass preferences.sessionStorageAdapter. Any object with async getItem(key), setItem(key, value) and removeItem(key) works, for example AsyncStorage. Without one, the session ends when the app restarts.
- Codes suit a native app better than links: sendLoginOtp(identifier), then verifyOtp(code, identifier) and signInWithTokenPayload(data.authPayload).
- OAuth opens scuteClient.getOAuthUrl("google") in a WebView. When the WebView reaches a URL with sct_oauth or sct_magic, pass that URL to the client:
onNavigationStateChange={async (event) => { if (!scuteClient.getMagicLinkToken(event.url)) return; const { error } = await scuteClient.signInWithMagicLink(event.url); if (!error) setOAuthUrl(null);}}Vue and Svelte#
Create one client for the app and use onAuthStateChange to keep your own state in sync.
import { createClient } from "@scute/js-core";export const scute = createClient({ appId: import.meta.env.VITE_SCUTE_APP_ID });import { ref } from "vue";import { scute } from "./scute";export const user = ref(null);scute.onAuthStateChange((event, session, u) => { if (["initial_session", "signed_in", "signed_out", "session_expired", "token_refreshed"].includes(event)) { user.value = u; }});Then call scute.signInOrUp(email) from your form, as in the JavaScript quickstart.
Express#
Use getUser(token) from the Node recipe as middleware:
import { createClient } from "@scute/js-core";const scute = createClient({ appId: process.env.SCUTE_APP_ID });export async function requireUser(req, res, next) { const token = req.headers.authorization?.replace(/^Bearer /, ""); if (!token) return res.status(401).send("Unauthorized"); const { data, error } = await scute.getUser(token); if (error) return res.status(401).send("Unauthorized"); req.user = data.user; next();}See Authenticate requests for what getUser checks and how it fails.