infinity6i6 Builders Platform
Documentation

Getting started

Checking the session

Read the current user from the session with the web SDK.

1 min read

The SDK offers two ways to look at the session.

Querying the user

html
<script type="module">
  const sdk = new window.I6Sdk();
  const user = await sdk.auth().user();
  console.log(user);
</script>

sdk.auth().user() queries api/auth/me on the platform.

Requiring the session

html
<script type="module">
  async function main() {
    const sdk = new window.I6Sdk();
    const user = await sdk.auth().requireUser();
    if (!user) return;
    // from here on there is an active session
  }
  main();
</script>

requireUser() sends the browser to login when there is no active session. Use this form when the page loads, before any user action.

Full reference: auth().

Next step

Cookies and CORS

Requirements for the session to work across origins.

Continue