Before you start
- Create a workspace at https://auth.ziqme.com/signup. It starts on the Free plan; no card is needed.
- Open https://app.ziqme.com/auth-admin, choose "Register application", and add your redirect URI. A browser or mobile app is a public application (no secret). A server is confidential and gets a client secret, shown once.
- Note the client ID (it starts with app_). It is safe to ship in a browser: it is not a secret.
The SDK and component packages are not on npm or NuGet yet. For early access, contact Ziqme support at https://ziqme.com/contact. Meanwhile any standard OpenID Connect or JWT library works against Auth: every step here also works with one; see the plain OIDC quick start.
Client side
The React components keep the session in the browser, so they belong in a client component. Put the provider in one and use it from your root layout.
'use client'
import { useRouter } from 'next/navigation'
import { ZiqmeAuthProvider } from '@smartdesk/auth-react'
export function Providers({ children }: { children: React.ReactNode }) {
const router = useRouter()
return (
<ZiqmeAuthProvider
issuer="https://auth.ziqme.com"
clientId={process.env.NEXT_PUBLIC_ZIQME_AUTH_CLIENT_ID!}
redirectUri={`${process.env.NEXT_PUBLIC_APP_URL}/callback`}
onSignedIn={returnTo => router.replace(returnTo)}
>
{children}
</ZiqmeAuthProvider>
)
}Add an empty app/callback/page.tsx so the redirect URI resolves; the provider finishes the sign-in there.
Server side
A route handler receives the access token in the Authorization header and verifies it against Auth's published keys. Nothing is shared with the browser but the token.
import { verifyJwt } from '@smartdesk/auth-sdk'
export async function GET(request: Request) {
const token = request.headers.get('authorization')?.replace(/^Bearer /, '')
if (!token) return new Response('Unauthorized', { status: 401 })
try {
const claims = await verifyJwt(token, {
issuer: 'https://auth.ziqme.com',
audience: process.env.NEXT_PUBLIC_ZIQME_AUTH_CLIENT_ID!,
type: 'at+jwt',
})
return Response.json({ userId: claims.sub, roles: claims.roles ?? [] })
} catch {
return new Response('Unauthorized', { status: 401 })
}
}Server components cannot read a session kept in the browser. If you need the person on the server during rendering, run the authorization code flow on the server with a confidential application and keep your own cookie; the plain OIDC quick start shows the calls.