Starter kit with Next.js, Chakra-UI, Framer-Motion in Typescript. Internationalization, SEO, Components, Theme (dark/light) and more...

Overview

Typescript Next.js Chakra-UI Framer-Motion Starter Kit

Start with a powerful template ⚡️


Github Stars Code quality Code grade Top languages Opensource License


Table of contents

  • Getting started
  • Paths & Files
  • Useful dependencies (Important)
  • Components
  • Internationalization
  • Theme
  • Framer Motion
  • SEO

See a DEMO here.

Getting started

First, you need to open a Terminal and clone this repo by using :

git clone https://github.com/hakkaofdev/ts-next-chakra-motion-kit

Enter to the folder :

cd ./ts-next-chakra-motion-kit

And install dependencies (don't forget --force to force dependencies react 18):

npm install --force

Finally, run in dev :

npm run dev

Paths & Files

This is the main structure of the template.

Structure

.
├── data
├── .env
├── .eslintrc.json
├── next-env.d.ts
├── next-sitemap.js
├── package.json
├── .prettierrc.json
├── tsconfig.json
├── internationalization
│  ├── i18n.ts
│  └── locales
├── pages
│  ├── 404.tsx
│  ├── _app.tsx
│  ├── _document.tsx
│  └── index.tsx
├── public
│  └── assets
├── src
│  ├── components
│  ├── constants.ts
│  ├── providers
│  ├── theme
│  ├── types
│  └── utils
  • You can upload your constants like URL's in the constants.ts in .src/.
  • Dependencies can be found in package.json.
  • Your types in ./src/types.
  • The theme system of Chakra-UI in ./src/theme/.
  • Components in ./src/components/.
  • Pages in ./pages/
  • Locales for your langs in ./internationalization/locales/.
  • Default env variables in .env.

Customs Paths

For imports you can use this list :

  • @/components/*
  • @/types/*
  • @/utils/*
  • @/data/*
  • @/providers/*
  • @/internationalization/*
  • @/theme

Each imports refer to the specific folder.

Useful Dependencies

By default, I installed a list of useful dependencies.

  • react-use in v17.3.2 for useful hooks.
  • react-intersection-observer in v8.33.1 for advanced animations. You can find an example of use here.
  • prettier in v2.5.1 for formatting code.
  • eslint in v8.7.0 for errors.
  • react-country-flag in v3.0.2 for flags. Example here.
  • @react-icons/all-files in v4.1.0 for icons. React-Icons
  • Fonts to fontsource.org.

Components

  • <ThemeButton /> in .src/components/theme-button/index.tsx.
  • <LanguagesButton /> in .src/components/languages-button/index.tsx.
  • <PageLayout /> in .src/components/page-layout/index.tsx.

Internationalization

Default config

She can be found in ./internationalization/i18n.ts

const resources = {
  us: {
    translation: en_US,
  },
  fr: {
    translation: fr_FR,
  },
};

export const availableLanguages = Object.keys(resources);

i18n.use(initReactI18next).init({
  fallbackLng: 'us',
  lng: 'us',
  resources,
});

Add a new lang

Add it in ressources like others. Create un folder with prefix in ./internationalization/locales/ like others. And customize the constant in your .ts file.

export const en_US = {
  home: {
    title: 'Home',
  },
};

How to use it

import { Text } from '@chakra-ui/react';
import { useTranslation } from 'react-i18next';

const Example = () => {
  const { t } = useTranslation();

  return <Text align='center'>{t('home.title')}</Text>;
};

Theme

You can find a complete documentation here.

Framer Motion

Framer Motion was directly installed when @chakra-ui/react is added as dependency.

Use Framer Motion with Chakra-UI

First, you have to declare your variants :

import { Variants } from 'framer-motion';

const variants: Variants = {
  hidden: {
    opacity: 0,
    x: 0,
    y: -40,
    transition: { duration: 0.4, type: 'easeOut' },
  },
  enter: {
    opacity: 1,
    x: 0,
    y: 0,
    transition: { duration: 0.4, type: 'easeOut' },
  },
  exit: {
    opacity: 0,
    x: -0,
    y: 40,
    transition: { duration: 0.4, type: 'easeOut' },
  },
};

Declare your custom container, a MotionContainer !

import { Container, ContainerProps } from '@chakra-ui/react';
import { motion } from 'framer-motion';

const MotionContainer = motion<ContainerProps>(Container);

And use it as a component :

<MotionContainer
  display='flex'
  maxW='container.lg'
  minH={{ base: 'auto', md: '100vh' }}
  px={{ base: 4, lg: 8 }}
  initial='hidden'
  animate='enter'
  exit='exit'
  variants={variants}
  centerContent
>
  {children}
</MotionContainer>

You can find my article with an another example here.

SEO

The Search Engine Optimization (SEO) is important on any websites.

For this template, I used next-seo and next-sitemap.

Use the SEO

For that you've a PageLayout component with SEO. The default config for SEO is that:

<NextSeo
  title={title + ' | ' + process.env.siteName}
  description={description}
  twitter={{
    cardType: 'summary_large_image',
    handle: '@hakkaofdev',
  }}
  openGraph={{
    url: 'https://www.hakkaofdev.fr',
    title: title + ' | ' + process.env.siteName,
    description: description,
    locale: 'en_US',
    images: [
      {
        url: 'https://www.hakkaofdev.fr/assets/images/social.png',
        width: 1200,
        height: 630,
        alt: 'Alexandre Gossard',
        type: 'image/png',
      },
    ],
  }}
  additionalLinkTags={[
    {
      rel: 'icon',
      href: 'https://www.hakkaofdev.fr/favicon.ico',
    },
  ]}
/>

Just use it like this:

import PageLayout from '@/components/page-layout';

return (
  <PageLayout title='This is a template' description='Created by @HakkaOfDev'>
    {children}
  </PageLayout>
);

Sitemap

Default site-map.

module.exports = {
  siteUrl: process.env.baseURL,
  changefreq: 'daily',
  priority: 0.7,
  sitemapSize: 5000,
  generateRobotsTxt: true,
};

You have to npm run postbuild to generate it.

Don't hesistate to contact me if you want advices or if you have any questions or post an issues.

You might also like...

Parse/Next Monorepo Starter

Parse/Next Monorepo Starter All in one template monorepo to build and deploy apps faster than ever with modern technologies. Technologies Parse Server

Oct 27, 2022

Providing accessible components with Web Components & Material You

tiny-material Still on developing, DO NOT use for production environment Run well on Google Chrome, Firefox, Chrome for Android, Microsoft Edge (Chrom

Dec 31, 2022

Nextjs-components: A collection of React components

Nextjs-components: A collection of React components

nextjs-components A collection of React components, transcribed from https://vercel.com/design. 1 Motivation Blog post from 01/09/2022 Todo's Unit tes

Nov 30, 2022

📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!

📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!

Build bulletproof UI components faster Storybook is a development environment for UI components. It allows you to browse a component library, view the

Jan 4, 2023

Light-weight react-like maximum-optimistic library for building user interfaces.

wili Wili is a 2kb Light-weight react-like maximum-optimistic library for building user interfaces. Usage Welcome componenet: class Welcome extends Wi

Feb 16, 2022

Dynamic, theme-driven, style props for vanilla-extract.

Rainbow Sprinkles 🧁 Dynamic, theme-driven, style props for vanilla-extract. Rainbow sprinkles works similarly to @vanilla-extract/sprinkles. Like spr

Dec 23, 2022

Dynamic, theme-driven, style props for vanilla-extract.

Rainbow Sprinkles 🧁 Dynamic, theme-driven, style props for vanilla-extract. Rainbow sprinkles works similarly to @vanilla-extract/sprinkles. Like spr

May 11, 2022

Set of property utilities for Stitches with theme tokens support. Use the built-in utils, or easily build custom ones.

Stitches Mix Set of property utilities for Stitches with theme tokens support. Use the built-in utils, or easily build custom ones. Usage To import al

Aug 8, 2022

🔄 Basic project to start studying React and Typescript. With it you can translate text to binary or morse language. This project addresses the creation of routes and components.

max-conversion Projeto criado para iniciar nos estudos de React e Typescript Basic project to gain knowledge in react Na plataforma é possível convert

Feb 12, 2022
Comments
  • Hydratation issue with i18next

    Hydratation issue with i18next

    This issue appears when you'r on the website, change the language and refresh the page. In the console will appear the hydratation issues due to the difference between the server and the client. The error appears only in local not in production.

    bug 
    opened by HakkaOfDev 0
Releases(v0.2)
Owner
Alexandre Gossard
Developer, designer and devops. I'm creating more and more crazy projects and share them with you.
Alexandre Gossard
This simple and small react component can check your repository stars and change theme on light/dark

Repository metrics for react This beauty and easy (4KB) react component can help you add metrics to your repositories also you can change component th

Koma Human 2 Jun 25, 2022
Real state property listing app using next.js , chakra.ui, SCSS

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

null 1 Dec 19, 2021
React + Redux starter kit / boilerplate with Babel, hot reloading, testing, linting and a working example app built in

A comprehensive starter kit for rapid application development using React. Why Slingshot? One command to get started - Type npm start to start develop

Cory House 9.8k Dec 22, 2022
React Starter Kit — isomorphic web app boilerplate (Node.js, Express, GraphQL, React.js, Babel, PostCSS, Webpack, Browsersync)

React Starter Kit — "isomorphic" web app boilerplate React Starter Kit is an opinionated boilerplate for web development built on top of Node.js, Expr

Kriasoft 21.7k Dec 30, 2022
Internationalization for react done right. Using the i18next i18n ecosystem.

react-i18next IMPORTANT: Master Branch is the new v10 using hooks. $ v10.0.0 npm i react-i18next react-native: To use hooks within react-native, you m

i18next 7.9k Jan 9, 2023
This project was bootstrapped with Chakra UI & Create React App

Getting Started with Create React App This project was bootstrapped with Chakra UI & Create React App. ScreenShots Available Scripts In the project di

Pawan Kumar 51 Dec 11, 2022
Next.js + TypeScript + Material UI v5 + Sass + Storybook starter

nextjs-ts-mui5-scss-storybook-starter ?? Next.js + TypeScript + Material UI v5 + Sass + Storybook starter ?? with linting & prettier pre-configured Ma

Muhammad Ridho Anshory 13 Oct 19, 2022
A forkable Next.js site w/ a blank custom Nextra theme (w/Tailwind)

Nextra Blank Custom Theme/Boilerplate Example A nearly blank MDX blog/content site powered by a custom Nextra theme (see components/layout.js) w/Tailw

Jared Palmer 91 Jan 6, 2023
A React utility belt for function components and higher-order components.

A Note from the Author (acdlite, Oct 25 2018): Hi! I created Recompose about three years ago. About a year after that, I joined the React team. Today,

Andrew Clark 14.8k Jan 4, 2023
we are make our components in story book. So if we add some components you can find document and example of useage in storybook.

we are make our components in story book. So if we add some components you can find document and example of useage in storybook.

고스락 6 Aug 12, 2022