{"id":13805540,"url":"https://github.com/jcs224/oak_inertia","last_synced_at":"2025-04-10T23:25:37.803Z","repository":{"id":62422163,"uuid":"379996002","full_name":"jcs224/oak_inertia","owner":"jcs224","description":"Oak middleware for Inertia.js","archived":false,"fork":false,"pushed_at":"2022-11-26T19:43:48.000Z","size":13,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T20:12:44.383Z","etag":null,"topics":["deno","hacktoberfest","inertiajs","oak"],"latest_commit_sha":null,"homepage":"https://deno.land/x/oak_inertia","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcs224.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-24T17:00:16.000Z","updated_at":"2023-09-15T03:19:16.000Z","dependencies_parsed_at":"2023-01-22T06:02:57.296Z","dependency_job_id":null,"html_url":"https://github.com/jcs224/oak_inertia","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcs224%2Foak_inertia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcs224%2Foak_inertia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcs224%2Foak_inertia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcs224%2Foak_inertia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcs224","download_url":"https://codeload.github.com/jcs224/oak_inertia/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248313731,"owners_count":21082903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deno","hacktoberfest","inertiajs","oak"],"created_at":"2024-08-04T01:01:02.148Z","updated_at":"2025-04-10T23:25:37.784Z","avatar_url":"https://github.com/jcs224.png","language":"TypeScript","funding_links":[],"categories":["Adapters"],"sub_categories":["Server-side"],"readme":"# Inertia.js middleware for Oak framework\n\nThis middleware can be used to easily enable Inertia.js client libraries to interact with your Oak-based application. It checks for the Inertia header from the client on request, and modifies the response accordingly. Supports both the Deno CLI and Deno Deploy environments.\n\n## Setup\n\n```js\nimport { Application, Router } from 'https://deno.land/x/oak/mod.ts'\nimport { Inertia } from 'https://deno.land/x/oak_inertia/mod.ts'\n\n// Instantiate Oak app\nconst app = new Application()\n\n// Provide a template string\n// Put '@inertia' somewhere in the body, which will be replaced by the Inertia bootstrapping frontend code\nconst template = `\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"UTF-8\"\u003e\n  \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"\u003e\n  \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"\u003e\n  \u003ctitle\u003eDeno and Inertia app\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  @inertia\n\u003c/body\u003e\n\u003c/html\u003e`\n\n// Optional function to determine Inertia version\nconst checkVersion = () =\u003e {\n  return Deno.env.get('OPTIONAL_INERTIA_VERSION')\n}\n\n// Add Inertia middleware to global Oak middleware stack\napp.use(Inertia.initMiddleware(template, checkVersion))\n\n// Use the Oak router\nconst router = new Router()\n\n// use the 'inertia.render()' method now attached to the Oak context to render an Inertia page\nrouter.get('/', (ctx, next) =\u003e {\n  const componentName = 'HomePage'\n  const payloadObject = {\n    username: 'johndoe',\n    email: 'jdizzle@example.com'\n  }\n\n  ctx.state.inertia.render(componentName, payloadObject)\n})\n```\n\n## SSR\n\nBecause React and Deno both use similar JavaScript functionality, SSR on initial page load is pretty feasible to achieve!\n\nFull instructions aren't available yet on how to do this, but for now, here is an optional argument to inject custom server-side code into the initial template.\n\n### Example Oak route with SSR string\n```ts\n// Make sure you have React loaded in Deno\nimport React from 'https://cdn.skypack.dev/react@17.0.2'\nimport { renderToString } from 'https://cdn.skypack.dev/react-dom@17.0.2/cjs/react-dom-server.browser.production.min.js'\n\n// Import a server-side render-able component\nimport ReactPage from './Pages/ReactPage.tsx'\n\n// Example Oak route with SSR string\nrouter.get('/', (ctx, next) =\u003e {\n  const componentName = 'HomePage'\n  const payloadObject = {\n    username: 'johndoe',\n    email: 'jdizzle@example.com'\n  }\n\n  ctx.state.inertia.render(componentName, payloadObject, renderToString(\u003cReactPage { ...payloadObject } /\u003e))\n})\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcs224%2Foak_inertia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcs224%2Foak_inertia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcs224%2Foak_inertia/lists"}