Recap

The last section covered how to add a page route in the app plugin and how a view can consume the response. Get caught up by making sure your project looks like the following.
PROJECT
config
develop.ts
plugins
app
pages
home.ts
views
home.tsx
plugin.ts
package.json
tsconfig.json
develop.ts
home.ts
home.tsx
plugin.ts
package.json
tsconfig.json
Copy
If you are all caught up, then you can proceed to the next section.

4. Server Props

By default, Stackpress will pass the following props to both the and the function component for all views.
  • - User session data. by default.
  • - Serialized version of the request object
  • - Serialized version of the response object
  • - Template only data to pass to the view
  • - A list of styles that should be added to the function component
The following describes the exact type specifics of the server props.
Copy

4.1. Get Server Props

In your view files, you can access the server props like this.
Copy

4.2. Custom Server Props

Let's change the plugins/app/pages/home.ts file with the following code.
Copy
Adding will add a new key to the data object that will be passed to the view. You can add any other key to the data object in the same fashion for the view to consume it. This is useful for passing all template related data to the view that is not necessarily part of the request or response objects. In your view file, you can access the template related props like this.
Copy

4.3. Check Point

In case you got lost along the way, here is a checkpoint of what your project should look like.
PROJECT
config
develop.ts
plugins
app
pages
home.ts
views
home.tsx
plugin.ts
package.json
tsconfig.json
develop.ts
home.ts
home.tsx
plugin.ts
package.json
tsconfig.json
Copy
The next section will provide a guide to setting up the view engine.