Next.js Discord

Discord Forum

Add custom data to cookies

Transvaal lion posted this in #help-forum
Open in Discord
Transvaal lionOP
import { createMiddlewareClient } from '@supabase/auth-helpers-nextjs'
import { NextResponse } from 'next/server'

import type { NextRequest } from 'next/server'

export async function middleware(req: NextRequest) {
  const res =
  const supabase = createMiddlewareClient({ req, res })
  await supabase.auth.getSession()

  return res

Hello. This is my middleware for Supabase Auth.
But this misses all the stripe data I added to the auto-generated fields in the DB.

Is there a way to add those to the cookies?

Eg. here's how I use the auth:

import { createServerComponentClient } from "@supabase/auth-helpers-nextjs";
import { cookies } from "next/headers";
import Generate from "@/components/Generate";
import Link from "next/link";
import "../../(public)/globals.css";

export default async function Index() {
    const supabase = createServerComponentClient({ cookies });

    const {
        data: { user },
    } = await supabase.auth.getUser();

    return (
                display: "flex",
                justifyContent: "center",
                alignItems: "center",
                height: "100vh",
                width: "60vw",
                <h1 className="text-2xl font-bold text-center">sync. labs</h1>

                {user ? (
                    <div className="mt-4">
                ) : (
                    <div className="mt-4">
                        <Link href="/login">Please login to continue</Link>

1 Reply

Transvaal lionOP
Going with a other fix now