1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/website/docs/tutorials/getting-started.md
Mark Fulton a3b4e9db5f
docs: updated sidebars and added missing doc ID (#4993)
Updated `sidebars.js` to incorporate `Getting Started` as top level doc,
with Unleash Academy in child structure (order as discussed with
@dgorton ). See screenshot.

Also added missing `id` to `getting-started.md`


![image](https://github.com/Unleash/unleash/assets/128738155/52881918-a38b-4e6a-b6c8-bbeb1cd0a232)
2023-10-10 16:18:59 -05:00

4.3 KiB

id title
getting-started Getting Started

Set up Unleash

Run Unleash in Docker

The easiest way to run unleash locally is using git and docker.

git clone git@github.com:Unleash/unleash.git
cd unleash
docker compose up -d

Click here to see all options to get started locally.

Then point your browser to localhost:4242 and log in using:

username: admin
password: unleash4all

Unleash Demo Instance

For testing purposes we have set up a demo instance that you can use in order to test out different use-cases before setting up your own instance. You can find the demo instance here: https://app.unleash-hosted.com/demo/

NOTE: This is a demo instance set up with the Enterprise version. Some of the functionality may be enterprise specific, but everything we cover here is also available in open source.

Unleash Pro & Enterprise Instances

You can run Unleash in the cloud by using our hosted offerings. Please see the plans page to learn more.

Create your first flag

Step 1: Navigate to the Feature toggles list

Step 2: Click 'New feature toggle'

Step 3: Give it a unique name, and click 'Create feature toggle'

For a detailed guide on how to create a flag through the UI, you can follow this guide.

Connect a client-side SDK

If you have set up your own Unleash instance and are using the front-end API, then create a front-end token and use <your-unleash-instance>/api/frontend as the API URL.

If you don't have your own Unleash instance set up, you can use the Unleash demo instance's frontend API. In that case, the details are:

  • API URL: https://app.unleash-hosted.com/demo/api/frontend
  • Frontend key: demo-app:default.bf8d2a449a025d1715a28f218dd66a40ef4dcc97b661398f7e05ba67

Now you can open your application code and connect through one of the client-side SDKs.

The following example shows you how you could use the JavaScript SDK to connect to the Unleash demo frontend API:

import { UnleashClient } from 'unleash-proxy-client';

const unleash = new UnleashClient({
  url: 'https://app.unleash-hosted.com/demo/api/frontend',
  clientKey: 'demo-app:default.bf8d2a449a025d1715a28f218dd66a40ef4dcc97b661398f7e05ba67',
  appName: 'my-app-name-frontend',
});

unleash.on('synchronized', () => {
  // Unleash is ready to serve updated feature flags.

  // Check a feature flag
  if (unleash.isEnabled('some-toggle')) {
    // do cool new things when the flag is enabled 
  }
});

Connect a backend SDK

If you have set up your own Unleash instance and want to connect using a backend SDK, then create a client token and use <your-unleash-instance>/api as the API URL.

If you don't have your own Unleash instance set up, you can use the Unleash demo instance's client key. In that case, the details are:

  • API URL: https://app.unleash-hosted.com/demo/api
  • Client key: 56907a2fa53c1d16101d509a10b78e36190b0f918d9f122d

Curl command test credentials and retrieve feature toggles:

curl https://app.unleash-hosted.com/demo/api/client/features \
-H "Authorization: 56907a2fa53c1d16101d509a10b78e36190b0f918d9f122d";

Now you can open up your application code and create a connection to Unleash using one of our SDKs. Here's an example using the NodeJS SDK to connect to the Unleash demo instance:

const { initialize } = require('unleash-client');
const unleash = initialize({
  url: 'https://app.unleash-hosted.com/demo/api/',
  appName: 'my-app-name-backend',
  instanceId: 'my-unique-instance-id',
  customHeaders: {
    Authorization: '56907a2fa53c1d16101d509a10b78e36190b0f918d9f122d',
  },
});

unleash.on('synchronized', () => {
  // Unleash is ready to serve updated feature flags.

  if(unleash.isEnabled('some-toggle')){
    // do cool new things when the flag is enabled 
  } 
});