Files
Remco Haszing 7aa5d16231 Use the automatic runtime for type checking (#83159)
Co-authored-by: Sebastian "Sebbie" Silbermann <silbermann.sebastian@gmail.com>
2025-09-02 12:35:42 +02:00
..

Hello World example

This example shows how to use react context api in our app.

It provides an example of using app/layout.tsx to include the context api provider and then shows how both the app/page.tsx and app/about/page.tsx can both share the same data using the context api consumer.

We start off by creating two contexts. One that actually never changes (CounterDispatchContext) and one that changes more often (CounterStateContext).

The app/page.tsx shows how to, from the home page, increment and decrement the context data by 1 (a hard code value in the context provider itself).

The app/about/page.tsx shows how to pass an increment value from the about page into the context provider itself.

Deploy your own

Deploy with Vercel

How to use

Execute create-next-app with npm, Yarn, or pnpm to bootstrap the example:

npx create-next-app --example with-context-api with-context-api-app
yarn create next-app --example with-context-api with-context-api-app
pnpm create next-app --example with-context-api with-context-api-app

Deploy it to the cloud with Vercel (Documentation).