react ctx 1

react ctx

ctx is a NextJS artifact.

ctx is a context object containing those properties (Source):

pathname - path section of URL
query - query string section of URL parsed as an object
asPath - String of the actual path (including the query) shows in the browser
req - HTTP request object (server only)
res - HTTP response object (server only)
err - Error object if any error is encountered during the rendering

Here is what the above code is Doing:
1. If the user is not logged in, redirect them to the login page.
2. If the user is logged in, redirect them to the home page.

Similar Posts