Skip to main content

Configure Ory

This guide shows how to set up the necessary dependencies and configurations to integrate Ory's identity management features into your application.

Prerequisites

Before starting, ensure you have:

  1. An Ory network account
  2. Your Ory project id
  3. Your development environment set up with your framework of choice

First, install the Ory SDK for your framework:

npm install @ory/client-fetch --save

2. Set up local development with Ory Tunnel

For local development, you'll need to use Ory Tunnel to connect your local application with Ory's APIs:

# Install Ory CLI using Homebrew
brew install ory/tap/cli

# Verify installation
ory help

After installing the CLI, start the tunnel to connect your local application with Ory's APIs:

# Start the tunnel (replace with your project id)
ory tunnel --project <project-id> http://localhost:3000
tip

To learn more about the Ory Tunnel, read the dedicated section of the Ory CLI documentation.

3. Configure the SDK

When using the tunnel, configure your SDK to use the local tunnel URL:

import { Configuration, FrontendApi } from "@ory/client-fetch"

const baseUrl = process.env.ORY_SDK_URL || "http://localhost:4000"
const ory = new sdk.FrontendApi(
new sdk.Configuration({
basePath: baseUrl,
}),
)

For production environments, configure the SDK to use the Ory Network URL:

import { FrontendApi, Configuration } from "@ory/client-fetch"

const ory = new FrontendApi(
new Configuration({
basePath:
process.env.ORY_SDK_URL || "https://$PROJECT_SLUG.projects.oryapis.com",
}),
)

export default ory