We just shipped add-mcp: think npx skills but for MCPs. One command to install MCPs across all your editors and agents
/Neon Auth/Set up OAuth

Set up OAuth

Add Google or GitHub sign-in to your application

Beta

The Neon Auth with Better Auth is in Beta. Share your feedback on Discord or via the Neon Console.

OAuth lets users sign in with their Google, GitHub, or Vercel account. Neon Auth handles the OAuth flow and creates a session after authorization.

Development mode

Google OAuth is enabled by default with shared credentials for development and testing. You can start using Google sign-in immediately without any configuration.

note

GitHub and Vercel OAuth require custom credentials and is not available with shared credentials. See Production setup to configure your own OAuth apps.

For production, configure your own OAuth app credentials for both providers. See Production setup below.

Sign in with OAuth

Call signIn.social() with your provider ("google", "github" or "vercel"). The SDK redirects the user to the provider's authorization page, then back to your callbackURL:

Google
GitHub
Vercel
src/App.jsx
import { authClient } from './auth';

const handleGoogleSignIn = async () => {
  try {
    await authClient.signIn.social({
      provider: "google",
      callbackURL: window.location.origin,
    });
  } catch (error) {
    console.error("Google sign-in error:", error);
  }
};

Handle the callback

After the provider redirects back to your app, check for a session:

src/App.jsx
import { authClient } from './auth';

useEffect(() => {
  authClient.getSession().then(({ data }) => {
    if (data?.session) {
      setUser(data.session.user);
    }
    setLoading(false);
  });
}, []);

Custom redirect URLs

Specify different URLs for new users or errors:

src/App.jsx
await authClient.signIn.social({
  provider: "google", // or "github", "vercel"
  callbackURL: "/dashboard",
  newUserCallbackURL: "/welcome",
  errorCallbackURL: "/error",
});

Production setup

For production, configure your own OAuth app credentials. GitHub and Vercel OAuth require custom credentials, while Google OAuth works with shared credentials for development but should use custom credentials in production.

  1. Create OAuth apps with your providers:
  2. In your project's SettingsAuth page, configure your Client ID and Client Secret for each provider

Your app will automatically use your configured credentials

Need help?

Join our Discord Server to ask questions or see what others are doing with Neon. For paid plan support options, see Support.

Last updated on

Was this page helpful?