import { GetServerSideProps, GetServerSidePropsContext } from 'next';
import { CookieOptions } from '../types';
/**
* ## Protecting Pages with Server Side Rendering (SSR)
* If you wrap your `getServerSideProps` with {@link withPageAuth} your props object will be augmented with
* the user object {@link User}
*
* ```js
* // pages/profile.js
* import { withPageAuth } from '@supabase/supabase-auth-helpers/nextjs';
*
* export default function Profile({ user }) {
* return
Hello {user.name}
;
* }
*
* export const getServerSideProps = withPageAuth({ redirectTo: '/login' });
* ```
*
* If there is no authenticated user, they will be redirect to your home page, unless you specify the `redirectTo` option.
*
* You can pass in your own `getServerSideProps` method, the props returned from this will be merged with the
* user props. You can also access the user session data by calling `getUser` inside of this method, eg:
*
* ```js
* // pages/protected-page.js
* import { withPageAuth, getUser } from '@supabase/supabase-auth-helpers/nextjs';
*
* export default function ProtectedPage({ user, customProp }) {
* return Protected content
;
* }
*
* export const getServerSideProps = withPageAuth({
* redirectTo: '/foo',
* async getServerSideProps(ctx) {
* // Run queries with RLS on the server
* const { data } = await supabaseServerClient(ctx).from('test').select('*');
* return { props: { data } };
* }
* });
* ```
*
* @category Server
*/
export default function withPageAuth({ authRequired, redirectTo, getServerSideProps, cookieOptions, tokenRefreshMargin }?: {
authRequired?: boolean;
redirectTo?: string;
getServerSideProps?: GetServerSideProps;
cookieOptions?: CookieOptions;
tokenRefreshMargin?: number;
}): (context: GetServerSidePropsContext) => Promise;
//# sourceMappingURL=withPageAuth.d.ts.map