Quickstart

Make a flag and read it from a Node.js or Bun server. For browsers, mobile apps or other languages, follow steps 1 to 4, then go to OFREP.

  1. Sign in

    Go to app.slydog.dev and sign in with GitHub or Google. Slydog makes an organization for you, and you're its owner.

  2. Create an app

    Choose Create your first app. Give it a name; the key is filled in for you.

    Context kinds are what your keys identify. It starts with user, which is all most apps need. Add others, such as home or device, if you want to target or roll out by them. You can change these later.

    Every app gets three environments: local, development and production. Production is protected, so changes there ask you to confirm.

  3. Create a flag

    Open Flags and make a new flag, say new-checkout, of type Boolean. A boolean flag has two variations, on and off.

    The flag starts off in every environment, serving its off variation, so nothing changes for anyone until you turn it on.

  4. Make a server key

    Open Environments, choose development, and under SDK keys choose + Server key. Copy it: it starts with sly_srv_ and is only shown once. Keep it secret, like a database password.

    Each environment has its own keys, so the key decides which environment's rules your server reads.

  5. Install the provider

    npm install @slydogdev/openfeature-provider @openfeature/server-sdk

    Or bun add, pnpm add or yarn add.

  6. Read the flag

    import { OpenFeature } from "@openfeature/server-sdk"
    import { SlydogProvider } from "@slydogdev/openfeature-provider"
    
    await OpenFeature.setProviderAndWait(
      new SlydogProvider({
        sdkKey: process.env.SLYDOG_SERVER_KEY,
        baseUrl: "https://api.slydog.dev",
      }),
    )
    const flags = OpenFeature.getClient()
    
    const on = await flags.getBooleanValue("new-checkout", false, {
      targetingKey: user.id,
    })

    Set SLYDOG_SERVER_KEY to your key and run it: on is false, because the flag is off. The second argument, false, is the default your code gets if the flag doesn't exist or Slydog can't be reached.

  7. Turn it on

    In the app, open new-checkout in development and switch it On. The flag's Default rule decides what everyone gets when it's on. Set it to serve on, or a percentage rollout to give it to some of your users, and save.

    Your server picks up the change within moments, without restarting. Evaluate the flag again and on is true.

Next