Next.js Example

Craft your next amazing library using

Harness the full potential of React 18 Server Components!

Using treeshakable store

When the global store is created with treeshakable, it works well irrespective of from which file the component is imported.


import { Counter } from "@repo/shared/dist/client/counter";
import { Display } from "@repo/shared/dist/client/display";

Counter 1 Controls

Counter 1 Display

Count is: 0

Using global store without treeshakable

Works only when components are imported from same file.

import { Counter2, Display2 } from "@repo/shared";

Counter 2 Controls

Counter 2 Display

Count is: 0

Does not work when components imported from idividual files.

import { Counter2 } from "@repo/shared/dist/client/counter2";
import { Display2 } from "@repo/shared/dist/client/display2";

Counter 2 Controls

Counter 2 Display

Count is: 0

Docs ->

Check out the official documentation for more information.

More Examples ->

Check out more examples on the official GitHub Repo. Feel free to suggest additional examples in the discussions section.

Star this repo ->

Star this repo for your new library! This also motivates us and helps us understand that community is interested in this work.

Fork Me on GitHub