Prerequisites
Any runtime / server that supports standardReqiest and Response objects, for example:
- Bun
- Deno
- Node.js (v18) - with some configuration
- Cloudflare Workers - with some configuration
1. Install inertia-server
2. Create server helpers
On the server, we have to create the inertia helpers. They are used to define pages and parse your requests to handle inertia requests.render function defines how first inertia request is rendered to html.
You can use your framework server-side rendering features to render the page,
or return a raw html string. Inertia server protocol requires us to provide a
div in the markup with data-page attribute that contains the json encoded
initial page data.
~/server/inertia.ts
Step 3: Connect inertia to your server
On each request that works with inertia, you will create a helper that handles all inertia related logic and prepares the correct server response. Any inertia requests that require session features (flashing, errors), require a flash adapter to be provided. Its role is to get and set session flash data for the current request.app.ts
elysia
hono
Step 5: Setup inertia on the client
Follow the official documentation for your framework of choice. You will have to setup bundling of your client side code. To make things easier, we have a dedicated bundling integration section in the documentation.Step 6: Create your first page
Define your props on the server:~/server/inertia.ts
~/ui/homepage.tsx
Next Steps
Congratulations on setting up inertia! Now you can start building your application.- Learn about page definitions
- See our ecosystem integrations