Skip to content

Can I set custom cookies when successfully logged in? #4428

Answered by gride29
dipak-webo asked this question in Help
Discussion options

You must be logged in to vote

That works, if you are having problems with TypeScript types, simply change [...nextauth].ts file to [...nextauth].js.

Example working code that saves cookies:

import axios from "axios";
import NextAuth from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
import GithubProvider from "next-auth/providers/github";
import GoogleProvider from "next-auth/providers/google";
import { setCookie } from "nookies";

const nextAuthOptions = (req, res) => {
	return {
		providers: [
			GithubProvider({
				clientId: process.env.GITHUB_ID,
				clientSecret: process.env.GITHUB_SECRET,
			}),
			GoogleProvider({
				clientId: process.env.GOOGLE_CLIENT_ID,
				clientSecret: p…

Replies: 8 comments 18 replies

Comment options

You must be logged in to vote
1 reply
@OxiBo
Comment options

Comment options

You must be logged in to vote
1 reply
@dipak-webo
Comment options

Comment options

You must be logged in to vote
11 replies
@rnnyrk
Comment options

@tiriana
Comment options

@gride29
Comment options

Answer selected by dipak-webo
@DoronTorangy
Comment options

@gride29
Comment options

@DoronTorangy
Comment options

@gride29
Comment options

Comment options

You must be logged in to vote
5 replies
@gregoire-jianda
Comment options

@ezechuka
Comment options

@gregoire-jianda
Comment options

@microooji
Comment options

@microooji
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
question Ask how to do something or how something works
Converted from issue

This discussion was converted from issue #4403 on April 19, 2022 20:56.