moxystudio / next-layout Goto Github PK
View Code? Open in Web Editor NEWAdd persistent and nested layouts to your Next.js projects in a declarative way
License: MIT License
Add persistent and nested layouts to your Next.js projects in a declarative way
License: MIT License
Hey,
is it possible to use withLayout for each page?
My setup currently:
export const authenticated = (Component) => {
return withLayout(<AuthGuard><BaseLayout /></AuthGuard>)(Component)
}
export const public = (Component) => {
return withLayout(<BaseLayout />)(Component)
}
in each page i then use either authenticated(Component) or public(Component)
AuthGuard:
const AuthCheck = ({ children }) => {
const [isChecking, setChecking] = React.useState(true)
const router = useRouter()
const actions = useActions()
const state = useState()
React.useEffect(() => {
tryAuth()
}, [])
React.useEffect(() => {
if (state.authenticationCheckFailed) {
redirect()
}
}, [state.authenticationCheckFailed])
React.useEffect(() => {
if (state.authenticationCheckTried && state.isAuthenticated) {
setChecking(false)
}
}, [state.authenticationCheckTried])
const redirect = async () => {
const r = router.pathname.slice(1)
const redirectTo = r === 'login' ? '/' : '/' + r
router.push(`/login?r=${redirectTo}`)
// setChecking(false)
}
const tryAuth = async () => {
await actions.checkAuth(null)
}
if (isChecking) {
return (
<Centered>
<LoadingSpinner $style={{ borderTopColor: theme.colors.primary }} />
</Centered>
)
}
return children
}
export default AuthCheck
however this doesn't seem to work with SSR, it still is rendering my page Component first, then it renders my , even though it should not render any page component until (isChecking) is set to false (which happens if the user was authenticated)
Hello.
With this library is it possible to pass props from different pages to the layout component?
For example, imagine:
Greetings and thanks for the library.
is this support [email protected]
Hi, I had this bookmarked for a while to try it out sometime, but I want to ask - should this package be "deprecated" in favor of next.js 13's new app directory feature? At least to put into README a disclaimer that such a feature exists now and is probably preferable.
I can help :)
How do I pass props returned from getStaticProps
to the layout passed to withLayout
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.