This commit is contained in:
5
examples/next-with-pages/next-env.d.ts
vendored
Normal file
5
examples/next-with-pages/next-env.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||
7
examples/next-with-pages/next.config.js
Normal file
7
examples/next-with-pages/next.config.js
Normal file
@@ -0,0 +1,7 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
reactStrictMode: true,
|
||||
experimental: {},
|
||||
};
|
||||
|
||||
module.exports = nextConfig;
|
||||
21
examples/next-with-pages/package.json
Normal file
21
examples/next-with-pages/package.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "next-with-pages",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -p 4000",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": "20.5.7",
|
||||
"@types/react": "18.2.21",
|
||||
"@types/react-dom": "18.2.7",
|
||||
"next": "13.4.19",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"typescript": "5.2.2",
|
||||
"@aptabase/react": "*"
|
||||
}
|
||||
}
|
||||
25
examples/next-with-pages/src/components/Counter.tsx
Normal file
25
examples/next-with-pages/src/components/Counter.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { useAptabase } from '@aptabase/react';
|
||||
import { useState } from 'react';
|
||||
|
||||
export function Counter() {
|
||||
const { trackEvent } = useAptabase();
|
||||
const [count, setCount] = useState(0);
|
||||
|
||||
function increment() {
|
||||
setCount((c) => c + 1);
|
||||
trackEvent('increment');
|
||||
}
|
||||
|
||||
function decrement() {
|
||||
setCount((c) => c - 1);
|
||||
trackEvent('decrement');
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<p>Count: {count}</p>
|
||||
<button onClick={increment}>Increment</button>
|
||||
<button onClick={decrement}>Decrement</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
10
examples/next-with-pages/src/pages/_app.tsx
Normal file
10
examples/next-with-pages/src/pages/_app.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { AptabaseProvider } from '@aptabase/react';
|
||||
import type { AppProps } from 'next/app';
|
||||
|
||||
export default function App({ Component, pageProps }: AppProps) {
|
||||
return (
|
||||
<AptabaseProvider appKey="A-DEV-0000000000">
|
||||
<Component {...pageProps} />
|
||||
</AptabaseProvider>
|
||||
);
|
||||
}
|
||||
13
examples/next-with-pages/src/pages/_document.tsx
Normal file
13
examples/next-with-pages/src/pages/_document.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Html, Head, Main, NextScript } from 'next/document'
|
||||
|
||||
export default function Document() {
|
||||
return (
|
||||
<Html lang="en">
|
||||
<Head />
|
||||
<body>
|
||||
<Main />
|
||||
<NextScript />
|
||||
</body>
|
||||
</Html>
|
||||
)
|
||||
}
|
||||
9
examples/next-with-pages/src/pages/api/hello.ts
Normal file
9
examples/next-with-pages/src/pages/api/hello.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
|
||||
type Data = {
|
||||
name: string;
|
||||
};
|
||||
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse<Data>) {
|
||||
res.status(200).json({ name: 'John Doe' });
|
||||
}
|
||||
23
examples/next-with-pages/src/pages/index.tsx
Normal file
23
examples/next-with-pages/src/pages/index.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Counter } from '@/components/Counter';
|
||||
import { GetServerSideProps } from 'next';
|
||||
import Head from 'next/head';
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async ({ req }) => {
|
||||
return { props: {} };
|
||||
};
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Create Next App</title>
|
||||
<meta name="description" content="Generated by create next app" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
</Head>
|
||||
<main>
|
||||
Aptabase + Next.js Pages Router <br />
|
||||
<Counter />
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
}
|
||||
35
examples/next-with-pages/tsconfig.json
Normal file
35
examples/next-with-pages/tsconfig.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"./src/*"
|
||||
]
|
||||
},
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user