0.2.0 • Published 2 months ago

@ory/elements-markup v0.2.0

Weekly downloads
-
License
Apache License 2....
Repository
github
Last release
2 months ago

Ory Elements

Ory Elements is a component library that makes building login, registration and account pages for Ory a breeze.

  • Reduces time to add complex auth flows to your customer experience, including multi-factor authentication and account recovery
  • Themeable and modular - use only what you need from it
  • Works with the React ecosystem (NextJS, React SPA, Preact SPA)
  • Works with the Express based ecosystem
  • Dynamically adapts the user interface to your Ory identity schema, sign-in and flow configuration

Ory Elements supports integrating with:

  • React
  • Preact
  • Express.js (experimental)

Getting Started

Install Ory Elements into your Express.js application

npm i @ory/elements-markup --save

In Express.js we can render the component server-side and inject the rendered HTML into the page using a template rendering engine. In this case, we could use Handlebars.js.

An important feature of Ory Elements is theming, which can be done through its css variables.

In Express.js Ory Elements provides us with helper routes to expose static css files as well as a way to override those css variables to essentially theme the page.

Create a route for static files static.ts.

export const registerStaticRoutes: RouteRegistrator = (app) => {
  RegisterOryElementsExpress(app, {
    ...defaultLightTheme, // we can add new theming variables
  })
}

Create a view template called login.hbs which will accept raw HTML through the card property.

<div id="login">
  {{{card}}}
</div>

Create a new login route in login.ts which does all the logic for the login flow.

// do sdk calls to get the flow data
// render the view template `login.hbs`
res.render("login", {
  card: UserAuthCard({
    title: !(flow.refresh || flow.requested_aal === "aal2")
      ? "Sign In"
      : "Two-Factor Authentication",
    ...(flow.hydra_login_request && {
      subtitle: `To authenticate ${
        flow.hydra_login_request.client_client_name ||
        flow.hydra_login_request.client_client_id
      }`,
    }),
    flow: flow as SelfServiceFlow,
    flowType: "login",
    cardImage: "ory-logo.svg",
    additionalProps: {
      forgotPasswordURL: "recovery",
      signupURL: initRegistrationUrl,
      logoutURL: logoutUrl,
    },
  }),
})

An example implementing Ory Elements can be found at ory/kratos-selfservice-ui-node on GitHub.

0.1.0-beta.17

2 months ago

0.2.0

2 months ago

0.1.0-beta.16

3 months ago

0.1.0-beta.15

4 months ago

0.1.0-beta.14

5 months ago

0.1.0-beta.13

5 months ago

0.1.0-beta.3

8 months ago

0.1.0-beta.2

8 months ago

0.1.0-beta.5

8 months ago

0.1.0-beta.4

8 months ago

0.1.0-beta.1

9 months ago

0.1.0-beta.10

7 months ago

0.1.0-beta.12

6 months ago

0.1.0-beta.11

7 months ago

0.1.0-beta.7

8 months ago

0.1.0-beta.6

8 months ago

0.1.0-beta.9

8 months ago

0.1.0-beta.8

8 months ago

0.0.1-beta.7

10 months ago

0.0.1-beta.9

9 months ago

0.0.1-beta.8

9 months ago

0.0.1-beta.10

9 months ago

0.0.1-beta.12

9 months ago

0.0.1-beta.11

9 months ago

0.0.1-beta.13

9 months ago

0.0.1-beta.6

1 year ago

0.0.1-beta.5

1 year ago

0.0.1-beta.4

1 year ago

0.0.1-alpha.30

1 year ago

0.0.1-beta.3

1 year ago

0.0.1-beta.2

1 year ago

0.0.1-beta.1

1 year ago

0.0.1-alpha.29

1 year ago

0.0.1-alpha.28

1 year ago

0.0.1-alpha.27

1 year ago

0.0.1-alpha.26

2 years ago

0.0.1-alpha.25

2 years ago

0.0.1-alpha.11

2 years ago

0.0.1-alpha.10

2 years ago

0.0.1-alpha.9

2 years ago

0.0.1-alpha.8

2 years ago

0.0.1-alpha.3

2 years ago