Β© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabaseβ€’4y agoβ€’
6 replies
b3n123

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);
  }
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.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Permission based withPageAuth
SupabaseSSupabase / help-and-questions
4y ago
Server Side Dynamic Page
SupabaseSSupabase / help-and-questions
4y ago
withPageAuth redirectTo, how to go back to previous page after login?
SupabaseSSupabase / help-and-questions
4y ago
Using withPageAuth without a session
SupabaseSSupabase / help-and-questions
4y ago