Framer
For Framer sites that already sign visitors in through another service: Memberstack, Outseta, Auth0, Clerk or your own.
Before you start
In GetSupportX, open Settings → Help center & portal → Portal sign-in and switch on Sign in through your website. Answer What is your website built on? with Framer.
Under 1 · Secret key, click Create secret key. Copy the key straight away: it is shown once. The code on this page needs it.
Copy the code from 2 · Add the code to your website: your callback URL is already filled in there. Copying the code from this page instead? Replace the whole https://<your-help-center>/portal/handoff address with the Callback URL Settings shows under For developers in step 2. Don’t build it by hand: it isn’t the same for every help center.
Steps
Deploy the function below
The example is a Vercel Function. Add
GSX_SSO_SECRET(your secret key) to its environment.Recognise the visitor
Write
identifyVisitor(request): it asks your login service who this visitor is and returns their id, email and name, or nothing.Set your site’s address and login page
Set
SITEto your Framer site’s address, and the login address to wherever your visitors log in.Set your sign-in link
The function’s address, for example
https://your-function.vercel.app/api/support.
The code
// api/support.js — a Vercel Function (Framer sites have no server of their own).
// NEEDS A DEVELOPER: Framer has no customer accounts, so this only works if
// you already sign visitors in with something else (Memberstack, Outseta,
// Auth0, Clerk, your own API). Needs GSX_SSO_SECRET in your environment.
// Your sign-in link: https://<your-project>.vercel.app/api/support
import crypto from "node:crypto";
// Your Framer site's address — keeps customer ids unique. Never change it.
const SITE = "https://yourwebsite.com";
const CALLBACK = "https://<your-help-center>/portal/handoff";
// The portal page the customer was heading to (a ticket from an email, say),
// which the portal sends as ?gsx_return=. Only a plain path is passed on —
// GetSupportX checks it again before using it.
function returnPath(value) {
return typeof value === "string" && value.startsWith("/") &&
!value.startsWith("//") && !value.startsWith("/\\") ? value : "";
}
// Signs the customer's details with your SSO secret and sends them to the
// portal. Never cached: the link inside signs one person in.
function signedCallbackUrl(payload, back) {
const secret = process.env.GSX_SSO_SECRET;
if (!secret) throw new Error("GSX_SSO_SECRET is not set — paste your SSO secret into your environment.");
const now = Math.floor(Date.now() / 1000);
// jti: a one-time id, so this exact link can never be used twice.
const body = { ...payload, iat: now, exp: now + 300, jti: crypto.randomBytes(16).toString("hex") };
const b64 = Buffer.from(JSON.stringify(body), "utf8").toString("base64");
const sig = crypto.createHmac("sha256", secret).update(b64).digest("hex");
let url = CALLBACK + "?payload=" + encodeURIComponent(b64) + "&sig=" + sig;
if (returnPath(back)) url += "&redirect=" + encodeURIComponent(back);
return url;
}
function signInRedirect(payload, back) {
return redirectTo(signedCallbackUrl(payload, back));
}
function redirectTo(url) {
return new Response(null, { status: 302, headers: { Location: url, "Cache-Control": "no-store" } });
}
export async function GET(request) {
const user = await identifyVisitor(request); // your implementation — see above
// Your login page. If it can send people back afterwards, send them to "next"
// (this full address) so they reach the page they wanted.
if (!user) return redirectTo(SITE + "/login?next=" + encodeURIComponent(request.url));
return signInRedirect({
externalId: new URL(SITE).host + ":" + user.id,
site: SITE,
legacyExternalId: String(user.id), // keeps customers an older snippet created
email: user.email,
name: user.name,
}, new URL(request.url).searchParams.get("gsx_return"));
}Every version of this code signs the same way. The protocol reference lists each field and rule, including the optional customer details (plan, phone and more) you can add.
Check it works
Save your sign-in link
In Settings → Help center & portal → Portal sign-in, enter it under 3 · Sign-in link (for example
https://your-function.vercel.app/api/support) and click Save. What is the sign-in link?Click Test sign-in
Under Check it works. We open your link as a visitor who isn’t logged in. “Your sign-in link is live” means your link sent that visitor somewhere other than your homepage or the portal, and names the address. Check that address is your login page.
Try it as a customer
Log in to your website, then open your sign-in link. You should land in your portal, signed in. If not, Check it works lists the reason under recent failed sign-ins, and Troubleshooting says how to fix it.
Good to know
- The function runs at its own address, not on your Framer site. Your developer needs a way for it to recognise the visitor there, and how depends on your login service.
- No accounts on your site? You don’t need this. Customers sign in with a link we email them.
Read next