nextjs friend is a nextjs boilerplate.
- layout system
- middleware (hoc)
- redux
- organize folder structure
All layouts will live inside layout folder. Then register your layout ./utils/nextjs-friend.tsx
let LayoutEnum: any = {
'base': Base,
}- usages of layout
import type { NextPage } from 'next'
import FriendHoc from '@utils/nextjs-friend'
const YourPageName: NextPage = () => {
return (
<div>
// your code
</div>
)
}
export default FriendHoc(YourPageName, {
layout: 'base',
})Auth middleware.
export default FriendHoc(YourPageName, {
middleware: ['auth'],
})redux (redux-toolkit) code will live inside store folder
- how to use redux toolkit with nextjs-friend.
import { useAppSelector, useAppDispatch } from '@utils/redux-friend'
function YourPage() {
const dispatch = useAppDispatch()
const getReduxState = useAppSelector((state: any) => state.name.data)
}
export default YourPage- clone the project.
yarn install
yarn dev
# with ssr
yarn dev-server