> For the complete documentation index, see [llms.txt](https://fusionauth.io/docs/llms.txt)

# Step 2 - Login Button | FusionAuth Docs

Learn how to use FusionAuth by using an example application that has a login button defined.

# Step 2 - Login Button

[Edit on GitHub](https://github.com/FusionAuth/fusionauth-site/blob/main/astro/src/content/docs/get-started/start-here/step-2.mdx)

[View Markdown](https://fusionauth.io/docs/get-started/start-here/step-2.md)

To better understand how FusionAuth works, let's take a look at an example app. This app uses Node, Express, Typescript, and FusionAuth to secure a section of the app. This example may seem simple, but it demonstrates how to leverage FusionAuth for things like login and access controls.

You need Node `22.x` or newer to run this example.

1.  First, download the app from GitHub:
    
    ```shell-session
    $ git clone git@github.com:FusionAuth/fusionauth-example-get-started.git
    ```
    
2.  Then, navigate into the app directory:
    
    ```shell-session
    $ cd fusionauth-example-get-started
    ```
    
3.  Install the app dependencies:
    
    ```shell-session
    $ npm install
    ```
    
4.  Run the app:
    
    ```shell-session
    $ npm run dev
    ```
    
5.  Open [http://localhost:8080](http://localhost:8080) and you'll see the example app. Click the login button, and the app will redirect you to FusionAuth's login page.
    
6.  Finally, log in:
    
    *   If you are still logged in as the FusionAuth admin user, your browser will redirect you back to the example app. This is an example of FusionAuth's single sign-on (SSO) capabilities.
        
    *   If you aren't currently logged into FusionAuth, you will see a login page. You can use these credentials to log in as a non-admin:
        
        *   Username: `richard@example.com`
        *   Password: `password`
    
    You can find your current username at the top right of the app.
    

## How it works

Let's take a quick look at how this app interacts with FusionAuth. First, open `templates/home.html`: the homepage. You should see the following code:

```html
<div id="logo-header">
  <img src="https://fusionauth.io/cdn/samplethemes/changebank/changebank.svg" />
  <a class="button-lg" href="/login">Login</a>
</div>
```

This renders a login button that, when clicked, navigates to `/login`.

Open `src/index.mts`, which contains the Node and Express backend code. You should see the following route:

```typescript
app.get('/login', async (req, res) => {
  if (await sdk.userLoggedIn(req, res)) {
    res.redirect(302, '/account');
    return;
  }

  sdk.sendToLoginPage(res);
});
```

When someone opens this route in a browser, the app checks their login status:

*   If the user is logged in, the app redirects them to the `/account` page.
*   If the user isn't logged in, the app redirects them to the FusionAuth login page.

This example app organizes most of the OAuth, JWT, and cookie logic into a separate file named `sdk.ts`. Take a look at that file to get a better understanding of how this all comes together.

`sendToLoginPage()` redirects the user to the FusionAuth login page, following the OAuth specification. We won't go into detail about OAuth here, but the key takeaway is that this app integrates with FusionAuth using the OAuth standard.

## Next steps

[<- Step 1: Install](step-1)

[Step 3: Protected Pages \->](step-3)