No description
  • TypeScript 85.1%
  • JavaScript 8.8%
  • Pug 6.1%
Find a file
2021-09-20 10:14:17 +09:00
.github/workflows feat: implement inertia protocol 2021-09-19 23:21:44 +09:00
src x-inertia fix 2021-09-20 10:14:14 +09:00
test fix page title 2021-09-20 09:12:34 +09:00
.gitignore Initial commit 2021-09-19 22:27:05 +09:00
.prettierrc feat: implement inertia protocol 2021-09-19 23:21:44 +09:00
package.json 1.0.10 2021-09-20 10:14:17 +09:00
publish-version.js feat: implement inertia protocol 2021-09-19 23:21:44 +09:00
README.md fix readme 2021-09-20 10:11:56 +09:00
tsconfig.json test 2021-09-20 09:55:16 +09:00
yarn.lock feat: implement inertia protocol 2021-09-19 23:21:44 +09:00

Koa-Inertia

Unofficial server-side adapter for inertia.js

Install

yarn add @pikokr/koa-inertia

Usage(Typescript)

views/app.pug

doctype html

html(lang='ko')
    head
        title MyApp
        script(type='text/javascript' src='/dist/js/app.js')
    body
        #root(data-page=pageData)

Render

import {inertia} from '@pikokr/koa-inertia'
import views from "koa-views";

// ...

app.use(
    views(__dirname + '/views', {
        extension: 'pug',
    }),
)

app.use(inertia('app', '1' /* asset version */))

const router = new Router()

// ...

router.get('/', async ctx => {
    await ctx.inertia.render('Index', {test: 1234})
})

Shared data

app.use((ctx, next) => {
    ctx.inertia.share('share', 12345)
    return next()
})

Redirect

ctx.inertia.location('https://google.com')