Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

Custom _App with getInitialProps typescript example

import type { AppProps } from 'next/app'
import App, { AppContext, AppProps } from "next/app";

type TProps = AppProps & {
  example: string;
};

export function MyCustomApp({ Component, pageProps, example }: TProps) {
  return (
    <>
      <p>example: {example}</p>
      <Component {...pageProps} />
    </>
  );
}

MyCustomApp.getInitialProps = async (context: AppContext) => {
  const ctx = await App.getInitialProps(context);

  return { ...ctx, example: "foo" };
};

export default MyCustomApp;
Source by github.com #
 
PREVIOUS NEXT
Tagged: #Custom #getInitialProps #typescript
ADD COMMENT
Topic
Name
6+1 =