Skip to content
Discussion options

You must be logged in to vote

There is no mechanism within Next to do this, other than using getInitialProps as you mentioned.

If you do this then your page will not have the data it needs when you navigate to it via next/link. For example if you are on /page1 and then click a next/link to /page2, page2 will not know what data to have and will behave differently if getServerSideProps logic is not called. That is why getServerSideProps runs on the server and then makes a fetch call to get the data on the client.

I may want to make some API calls that don't want the code to be exposed to the client

There is no difference between this and rendering on the server - the data is still available to the client. There are no…

Replies: 8 comments 22 replies

Comment options

You must be logged in to vote
6 replies
@jamesmosier
Comment options

@nimeshvaghasiya
Comment options

@aldabil21
Comment options

@SamirMishra27
Comment options

@aldabil21
Comment options

Answer selected by jamesmosier
Comment options

You must be logged in to vote
11 replies
@denu5
Comment options

@patjakubik
Comment options

@denu5
Comment options

@stefvhuynh
Comment options

@Yankovsky
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@dmwin72015
Comment options

@Yankovsky
Comment options

@denu5
Comment options

@Faisal-Manzer
Comment options

@behzadev
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet