Introduction

Build applications using Osmos and AdonisJS

OsmosJS is a light-weight and agnostic server-side JSX runtime. This integration provides all the necessary tools to build AdonisJS applications with OsmosJS.

It is highly recommended to first discover OsmosJS before starting with the AdonisJS integration.

const LoginForm = async () => {
  const adonis = Adonis.getOrFail()
  const form = await adonis.form(LoginSchema)

  if (form.isSubmitted && form.isValid) {
    const user = await User.verifyCredentials(form.parsed.email, form.parsed.password)
    await adonis.context.auth.login(user)
    return adonis.redirect('/')
  }

  return (
    <Form form={form}>
      <input type="email" {...form.field('email')} />
      <input type="password" {...form.field('password')} />

      <button type="submit">Login</button>
    </Form>
  )
}
routes.ts
router.get('/login', ({ osmos }) => {
  return osmos.render(LoginForm)
})

On this page