React Native & Django Quickstart
This is a quickstart guide to help you integrate Descope with your React Native & Django application. Follow the steps below to get started.
Include the Descope React Native Package
Incorporate the Descope React Native SDK as a package. Run the following command:
Import the React Native SDK
Proceed to import the Descope React Native package.
Initialize Descope with a Custom Project ID
Wrap your app with the Auth Provider and pass in the Descope Project ID (found on your Descope project page). This is needed to activate the SDK.
Note
Optionally, add the baseUrl
parameter if using a CNAME in your Descope project (ex: https://auth.company.com
).
Define and Host Your Flow
Your Descope console provides customizable, predefined authentication flows which are hosted for you. You can also host the flow yourself. You'll use the url of the hosted flow later in your code.
(Android Only) Configure App Links, Activity, and Linking
For Android (iOS works with just a flow url), follow the instructions in our README to establish App Links, create an activity, and handle token exchange.
Launch Your Flow
Use the flow 'start' function to initiate authentication with a custom flow (URL from step 6). For Android, add the deep link (URL from step 7).
Note
If you need to support Magic Link redirects, follow the steps in our README.
Leverage React Native SDK's Hooks and Session Management Functions
Descope provides many different hooks to check if the user is authenticated, session is loading etc. You can use these to customize the user experience:
useSession
- This is used for implementing loading screens while sessions are being established (checksession
), getting user information (session.user.name
), etc.useDescope
- Exposes the Descope SDK to your app for additional customization (e.g.,descope.logout()
).useFlow
- Used for handling flow related events (e.g.,flow.start()
).
For more specifics on implementing Session Management, check out our Mobile Session Validation page.
For backend Session Validation, continue reading!
At this point, you're done with the frontend. If you would like to also handle Session Management in your backend, keep on reading!
Install Backend SDK
Install the SDK with the following command:
Import and Setup Backend SDK
You'll need install and setup all of the packages from the SDK. This is done by ensuring django_descope
is under INSTALLED_APPS
in settings.py
.
If you're using a CNAME with your Descope project, make sure to export the Base URL (e.g. export DESCOPE_BASE_URI="https://api.descope.com"
) when initializing descope_client
.
Add Descope Middleware
Ensure Descope Middleware is after the AuthenticationMiddleware and SessionMiddleware.
Configure URLconf
You will then need to include the Descope URLconf in your project urls.py
like this.
Configure URLconf
The session validation is handled in the Django SDK, through the middleware.
Congratulations
Now that you've got the authentication down, go focus on building out the rest of your app!
Here is a sample application using the Django SDK.
Checkpoint
Your application is now integrated with Descope. Please test with sign-up or sign-in use case.
Customize
Now that you have the end-to-end application working, you can choose to configure and personalize many different areas of Descope, including your brand, style, custom user authentication journeys, etc. We recommend starting with customizing your user-facing screens, such as signup and login.