Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- The `StackHandler` (automatic page) in Stack Auth does not have a simple boolean prop like `hideSignUp` to remove that specific link. The pre-built `<SignIn />` component includes it by default.
- You have two options to remove it: **CSS hiding** (quickest) or building a **Custom Sign-in Page** (cleanest/official way).
- ### Option 1: The CSS Method (Quickest)
- Since you are using the automatic `StackHandler`, the easiest way is to hide the link using global CSS. The link is usually an anchor (`<a>`) tag at the bottom of the form.
- Add this to your `globals.css` file:
- ```css
- /* globals.css */
- /* Target the link by its href attribute usually containing 'sign-up' */
- .stack-theme a[href*="sign-up"] {
- display: none !important;
- }
- /* Alternatively, hide the entire footer text if it's just that link */
- .stack-theme .stack-sign-in-footer {
- display: none !important;
- }
- ```
- *Note: You may need to inspect the element in your browser (Right Click \> Inspect) to double-check the class name if `stack-theme` isn't the exact wrapper class in your version.*
- -----
- ### Option 2: Custom Page (The "Official" Way)
- For full control, you should tell Stack Auth to use your own page instead of the default one. This allows you to render *only* the inputs and buttons you want, effectively omitting the "Sign up" link.
- **Step 1: Create a custom Sign-in page**
- Create a file at `app/sign-in/page.tsx`. Instead of using the monolithic `<SignIn />` component (which includes the link), compose the form using the smaller parts:
- ```tsx
- // app/sign-in/page.tsx
- 'use client';
- import {
- CredentialSignIn,
- OAuthButtonGroup,
- useStackApp
- } from "@stackframe/stack";
- export default function CustomSignIn() {
- return (
- <div className="flex min-h-screen items-center justify-center">
- <div className="w-full max-w-md p-8 space-y-4 bg-white rounded shadow">
- <h1 className="text-2xl font-bold text-center">Sign In</h1>
- {/* 1. OAuth Buttons (Google, GitHub, etc.) */}
- <OAuthButtonGroup />
- <div className="relative flex py-2 items-center">
- <div className="flex-grow border-t border-gray-300"></div>
- <span className="flex-shrink-0 mx-4 text-gray-400">Or</span>
- <div className="flex-grow border-t border-gray-300"></div>
- </div>
- {/* 2. Email/Password Form */}
- <CredentialSignIn />
- {/* No Sign-Up link here! */}
- </div>
- </div>
- );
- }
- ```
- **Step 2: Update your Stack Server Config**
- Tell Stack Auth to redirect users to your new page instead of the automatic one.
- Open `stack.ts` (or wherever you initialized `StackServerApp`) and add the `urls` config:
- ```ts
- // stack.ts
- export const stackServerApp = new StackServerApp({
- tokenStore: 'nextjs-cookie',
- // ... other config
- urls: {
- signIn: '/sign-in', // Point to your new custom page
- // signUp: '/sign-up', // You can also point this elsewhere or leave it
- }
- });
- ```
- ### Summary
- * **Use CSS** if you want to keep the automatic page and just patch it visually.
- * **Use Option 2** if you want a properly customized page without hacky CSS selectors.
Advertisement
Add Comment
Please, Sign In to add comment