withPageAuth Dynamic Page

I need to make a dynamic page (e.g. [id].js) but I need to protect it using withPageAuth.

This is where I've got to so far but haven't been able to use the id in the query

export const getSererSideProps = (context) => {
    return withPageAuth({
        redirectTo: '/login',
        async getServerSideProps(ctx) {
            // Run queries with RLS on the server
    
            const { data: rows, error } = await supabase.from('table').select('*').eq('id', context.params.id).single()

            return {
                props: {
                    rows
                }
            }

        }
    })(context);
  }


How do I get the id from the URL to query the database with? I've seen another post on this forum where they use the id in the redirectTo but I don't know how to use it to query.

Any help would be much appreciated.
Was this page helpful?