Global state Next template (GSN) is designed for Next.js-based web applications utilizing global state and remote data sources. It includes the App Router configuration of Next.js and tests for React components, reducers, and hooks.
Static html deployment: Github pages
Full-featured deployment: Vercel
- Written in Typescript.
- Powered by Nextjs. Configured to use App router.
- Global state support using React.Context with devtools support.
- Remote data sources support with TanStack Query with devtools support.
- Generate components and features from CLI.
- pnpm for fast package management.
- Husky for git hooks.
- Eslint and stylelint.
- Jest and react-testing-library for testing.
- Supports CSS Modules and Styled components.
- Install Node >= 20.x.
- Install pnpm. E.g.
corepack prepare pnpm@latest --activate.
Manually clone repo or use degit.
# With CSS Modules config
npx degit github:morewings/ts-global-state-next my-app
# With Styled Components config
npx degit github:morewings/ts-global-state-next#styled-components my-app
cd ./my-app
pnpm iTemplate uses generate-react-cli. Templates are located at ./templates directory.
pnpm run generate:component FooCreates all necessary React component files in ./src/components/Foo.
pnpm run generate:component-loading FooCreates React component files for component with dynamically loading content in ./src/components/Foo.
pnpm run generate:feature-local FooCreates React.Context based feature with reducer, Context.Provider, hooks and selectors in ./src/features/Foo.
pnpm run generate:feature-connected FooCreates @tanstack/react-query based feature with global storage, queries, hooks and selectors in ./src/features/Foo.
pnpm run generate:page FooCreates Next App router compatible page in ./app/Foo directory.
Refer to this PR and styled-components branch for all necessary changes.
Cover frame image by GDJ.
