Skip to Content
This project is in active development. Features and behaviors may change without notice.
DocumentationUsageInitialization

Initialization

To use the SAuthBase SDK, you must call the init() method once somewhere in your application to initialize it.

Initialization requires specifying a secretKey (a 64-character hexadecimal string used for authentication) and a redirect_url to redirect to after authentication is complete.


Basic Initialization

src/index.ts
import { } from "sauthbase"; const = .({ : "your_64char_hex_secret_here", : "http://localhost:3000/auth" });

After initialization, you can access the same instance from anywhere using sauthbase.use():

src/index.ts
const = .(); const = .();

Notes

⚠️

Only call init() once within your application. Subsequent calls will be ignored.

  • Calling use() before init() will result in an error.
  • To check whether initialization has been completed, use sauthbase.isReady():
src/index.ts
if (!.()) { .({ : ..!, : ..! }); }

Common Errors

SituationError MessageSolution
use() called before init()SAuthBase has not been initialized.Run init() first
secretKey is too short/undefinedWarning appears in consoleUse a 64-character hexadecimal string
init() called multiple timesOnly the first call takes effectThis is normal behavior (no side effects)

You’ve now completed the initialization of the SAuthBase SDK.

Last updated on