Skip to content

Commit 443a9c6

Browse files
authored
Support ssr (#3)
* Formatting updates to README and WarrantProvider * Update webpack config to support SSR
1 parent b524faa commit 443a9c6

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Discord](https://img.shields.io/discord/865661082203193365?label=discord)](https://discord.gg/QNCMKWzqET)
55

66
## Overview
7-
The Warrant React library provides components, hooks, and helper methods for controlling access to pages and components in React using [Warrant](https://warrant.dev/). The library interacts directly with the Warrant API using a short-lived session token that must be created server-side using your API key. Refer to [this guide]() to see how to generate session tokens for your users.
7+
The Warrant React library provides components, hooks, and helper methods for controlling access to pages and components in React using [Warrant](https://warrant.dev/). The library interacts directly with the Warrant API using short-lived session tokens that must be created server-side using your API key. Refer to [this guide](https://docs.warrant.dev/guides/creating-session-tokens) to see how to generate session tokens for your users.
88

99
## Installation
1010

@@ -116,7 +116,7 @@ const MyComponent = () => {
116116
const fetchProtectedInfo = async () => {
117117
// Only fetch protected info from server if
118118
// user can "view" the info object "protected_info".
119-
if (await hasWarrant("info", "protected_info", "view")) {
119+
if (await hasWarrant("info", "protected_info", "viewer")) {
120120
// request protected info from server
121121
}
122122
};

src/WarrantProvider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React, { useCallback, useEffect, useState } from "react";
2-
import {Client as WarrantClient} from "@warrantdev/warrant-js";
2+
import { Client as WarrantClient } from "@warrantdev/warrant-js";
33

4-
import WarrantContext, { AuthorizationContext } from "./WarrantContext";
4+
import WarrantContext from "./WarrantContext";
55

6-
export interface AuthorizationProvider extends AuthorizationContext {
6+
export interface AuthorizationProvider {
77
clientKey: string;
88
children: React.ReactNode;
99
}

webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module.exports = env => {
3131

3232
filename: "index.js",
3333
path: path.resolve(__dirname, "dist"),
34+
globalObject: "this",
3435
},
3536

3637
externals: {

0 commit comments

Comments
 (0)