layout.tsx without a page.tsx?
Answered
Chausie posted this in #help-forum
ChausieOP
is is possible to only use layout.tsx as the base page? right now my page.tsx is just rendering null but i was thinking of it works to do it in another way so it looks more clean in the directories?
25 Replies
ChausieOP
its for shallow-routing basicly
i dont want any full refresh to happen in that specific url or child-urls
@Chausie i dont want any full refresh to happen in that specific url or child-urls
That URL will basically be cached on the client side
once its visited
ChausieOP
What i meant is that i dont want the components to re-render, therefore i am placing like nav-bar in my layout.tsx
and i dont need anything in my page.tsx
ChausieOP
but back to my original question
do i need to have the page.tsx? or is there a workaround to only use the layout.tsx?
"use client"
export default function UserPage() {
return null
}do i need to have the page.tsx? or is there a workaround to only use the layout.tsx?
1. your page.tsx should not be clientside. 2. yes ofc
page.tsx is essential for the nextjs app router
u cant define a route without it, as far as i know
Answer
ChausieOP
aha okay
i guess i will just keep retuning Null then
ye once i remove it i get 404 error
is your question solved?
@gin oh why?
ChausieOP
its mainly because i only use the {children} elements inside layout.tsx
@gin is your question solved?
ChausieOP
ye i guess 😄
cool
ChausieOP
ty guys for answering
u can mark this as answered :)
like this
ChausieOP
🙂