---
title: Quickstart (Pages Directory)
description: Integrate c15t into your Next.js pages directory application with this step-by-step guide. We'll cover installation, configuration, and basic usage.
lastModified: 2025-08-26
availableIn:
  - framework: 'javascript'
    url: '/docs/frameworks/javascript/quickstart'
    title: 'JavaScript'
  - framework: 'react'
    url: '/docs/frameworks/react/quickstart'
    title: 'React'
  - framework: 'next'
    url: '/docs/frameworks/next/quickstart/pages'
    title: 'Next.js'
---
## CLI Setup (Recommended)

You can get started with the `@c15t/cli` which will generate the code for you!

| Package manager | Command                       |
| :-------------- | :---------------------------- |
| npm             | `npx @c15t/cli generate`      |
| pnpm            | `pnpm dlx @c15t/cli generate` |
| yarn            | `yarn dlx @c15t/cli generate` |
| bun             | `bunx @c15t/cli generate`     |

## Manual Setup

1. **Install @c15t/nextjs Package**

   | Package manager | Command                    |
   | :-------------- | :------------------------- |
   | npm             | `npm install @c15t/nextjs` |
   | pnpm            | `pnpm add @c15t/nextjs`    |
   | yarn            | `yarn add @c15t/nextjs`    |
   | bun             | `bun add @c15t/nextjs`     |

2. **Next.js Rewrites (Optional)**

   > 💡 Tip:
   >
   > You can use Next.js Rewrites to redirect requests to the c15t backend. This is useful if you want to hide the c15t backend url from your users. Learn more about Next.js Rewrites.

   ```ts
   import type { NextConfig } from 'next';

   const config: NextConfig = {
   	async rewrites() {
   		return [
   			{
   				source: '/api/c15t/:path*',
   				destination: `${process.env.NEXT_PUBLIC_C15T_URL}/:path*`,
   			},
   		];
   	},
   };

   export default config;
   ```

3. **Adding it to your Next Application**

   ```tsx
   import { 
     ConsentManagerDialog,
     ConsentManagerProvider,
     CookieBanner,
   } from '@c15t/nextjs/pages';
   import type { AppProps } from 'next/app';

   export default function App({ Component, pageProps }: AppProps) {
     return (
       <ConsentManagerProvider
         initialData={pageProps.initialC15TData}
         options={{
           mode: 'c15t',
           backendURL: '/api/c15t',
           consentCategories: ['necessary', 'marketing'],
           ignoreGeoLocation: true,
         }}
       >
         <CookieBanner />
         <ConsentManagerDialog />
         <Component {...pageProps} />
       </ConsentManagerProvider>
     );
   }
   ```

   In every page you want to pre-fetch the data server-side, you can use the withInitialC15TData helper. Otherwise, it will be fetched client-side.

   ```tsx
   import { withInitialC15TData } from '@c15t/nextjs/pages';

   // This helper accepts a 2nd argument to wrap around your getServerSideProps existing function.
   export const getServerSideProps = withInitialC15TData('/api/c15t');

   ```

   > 💡 Tip:
   >
   > If you're using Next.js Rewrites, you can use the backendURL option to redirect requests to the c15t backend by setting it to /api/c15t.

***

## Storing Consent

We recommend using the [hosted solution](/docs/frameworks/next/storing-consent/hosted) with [consent.io](https://consent.io) to store your consent.
