import { GetServerSideProps, GetServerSidePropsContext, NextApiHandler, NextApiRequest, NextApiResponse } from 'next';
import { CookieOptions } from '../types';
export declare type WithAuthRequiredArg = {
redirectTo?: string;
getServerSideProps?: GetServerSideProps;
cookieOptions?: CookieOptions;
} | NextApiHandler;
/**
* @deprecated use `withPageAuth` instead!
* ## Protecting Pages with Server Side Rendering (SSR)
* If you wrap your `getServerSideProps` with {@link withAuthRequired} your props object will be augmented with
* the user object {@link User}
*
* ```js
* // pages/profile.js
* import { withAuthRequired } from '@supabase/supabase-auth-helpers/nextjs';
*
* export default function Profile({ user }) {
* return
Hello {user.name}
;
* }
*
* export const getServerSideProps = withAuthRequired({ 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 { withAuthRequired, getUser } from '@supabase/supabase-auth-helpers/nextjs';
*
* export default function ProtectedPage({ user, customProp }) {
* return Protected content
;
* }
*
* export const getServerSideProps = withAuthRequired({
* redirectTo: '/foo',
* async getServerSideProps(ctx) {
* // Run queries with RLS on the server
* const { data } = await supabaseServerClient(ctx).from('test').select('*');
* return { props: { data } };
* }
* });
* ```
*
* @deprecated use `withApiAuth` instead!
* ## Protecting API routes
* Wrap an API Route to check that the user has a valid session. If they're not logged in the handler will return a
* 401 Unauthorized.
*
* ```js
* // pages/api/protected-route.js
* import { withAuthRequired, supabaseServerClient } from '@supabase/supabase-auth-helpers/nextjs';
*
* export default withAuthRequired(async function ProtectedRoute(req, res) {
* // Run queries with RLS on the server
* const { data } = await supabaseServerClient({ req, res }).from('test').select('*');
* res.json(data)
* });
* ```
*
* If you visit `/api/protected-route` without a valid session cookie, you will get a 401 response.
*
* @category Server
*/
export default function withAuthRequired(arg?: WithAuthRequiredArg, options?: {
cookieOptions?: CookieOptions;
}): ((req: NextApiRequest, res: NextApiResponse) => Promise) | ((context: GetServerSidePropsContext) => Promise);
//# sourceMappingURL=withAuthRequired.d.ts.map