@frontegg/nextjs 5.7.1-alpha.2726809355 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +4 -214
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,217 +1,7 @@
1
- ![alt text](./logo.png)
1
+ # nextjs
2
2
 
3
- Frontegg is a web platform where SaaS companies can set up their fully managed, scalable and brand aware - SaaS features
4
- and integrate them into their SaaS portals in up to 5 lines of code.
3
+ This library was generated with [Nx](https://nx.dev).
5
4
 
6
- ## Table of Contents
5
+ ## Running unit tests
7
6
 
8
- - [Installation](#installation)
9
- - [Create new NextJS project](#create-new-nextjs-project)
10
- - [Add to existing project](#add-to-existing-project)
11
- - [Getting Started](#getting-started)
12
- - [Create Frontegg worksapce](#create-frontegg-worksapce)
13
- - [Setup environment](#setup-environment)
14
- - [Documentation](#documentation)
15
- - [API Reference](#api-reference)
16
- - [Frontegg Provider Options](#frontegg-provider-options)
17
- - [getSession](#getsession)
18
- - [withSSRSession](#withssrsession)
19
- - for more [visit](https://docs.frontegg.com/docs/self-service-introduction)
20
-
21
- ## Installation
22
-
23
- ### Create new NextJS project
24
-
25
- To start a new Create Next App project with TypeScript, you can run:
26
-
27
- ```bash
28
- npx create-next-app --example "https://github.com/frontegg/frontegg-nextjs/tree/main" --example-path "apps/example" my-nextjs-app-name
29
- ```
30
-
31
- or
32
-
33
- ```bash
34
- yarn create next-app --example "https://github.com/frontegg/frontegg-nextjs/tree/main" --example-path "apps/example" my-nextjs-app-name
35
- ```
36
-
37
- > If you've previously installed `create-react-app` globally via `npm install -g create-next-app`, we recommend you uninstall the package using `npm uninstall -g create-next-app` or `yarn global remove create-next-app` to ensure that `npx` always uses the latest version.
38
- >
39
- > Global installations of `create-next-app` are no longer supported.
40
-
41
- ### Add to existing project
42
-
43
- To Add Frontegg to your existing Nextjs project, follow below steps:
44
-
45
- 1. Use package manager to install Frontegg Next.JS library.
46
-
47
- ```bash
48
- npm install --save @frontegg/nextjs
49
- ```
50
-
51
- or
52
-
53
- ```bash
54
- yarn add --save @frontegg/nextjs
55
- ```
56
-
57
- 2. Wrap the default export with `withFronteggApp` in `./pages/_app.tsx`:
58
-
59
- ```tsx
60
- // ./pages/_app.tsx
61
-
62
- import { withFronteggApp } from '@frontegg/nextjs';
63
-
64
- function CustomApp({ Component, pageProps }: AppProps) {
65
- return <Component {...pageProps} />;
66
- }
67
-
68
- export default withFronteggApp(CustomApp);
69
- ```
70
-
71
- 3. Create files for frontegg middleware under `./pages/api/frontegg/[...frontegg-middleware].ts`:
72
-
73
- ```tsx
74
- // ./pages/api/frontegg/[...frontegg-middleware].ts
75
-
76
- export { fronteggMiddleware as default } from '@frontegg/nextjs';
77
- ```
78
-
79
- 4. Create placeholder pages for frontegg router under `./pages/[...frontegg-router].tsx`:
80
-
81
- ```tsx
82
- // ./pages/[...frontegg-router].tsx
83
-
84
- export {
85
- FronteggRouter as default,
86
- FronteggRouterProps as getServerSideProps,
87
- } from '@frontegg/nextjs';
88
- ```
89
-
90
- ## Getting Started
91
-
92
- ### Create Frontegg worksapce
93
-
94
- Navigate to [Frontegg Portal Settgins](https://portal.frontegg.com/development/settings), If you don't have application
95
- follow integration steps after signing up.
96
-
97
- Next, configure the "Allowed Origins" in your application under "Domain" tab of the "Settings" page :
98
-
99
- - http://localhost:3000 // for development environments
100
- - https://my-company-domain.com // for production environments
101
-
102
- Copy ClientID, Frontegg Domain from "Settings" page, You'll need these values in the next step.
103
-
104
- ### Setup environment
105
-
106
- To setup your Next.js application to communicate with Frontegg, you have to create a new file named `.env.local` under
107
- your root project directory, this file will be used to store environment variables that will be used, configuration
108
- options:
109
-
110
- ```dotenv
111
- # The AppUrl is to tell Frontegg your application hostname
112
- FRONTEGG_APP_URL='http://localhost:3000'
113
-
114
- # The Frontegg domain is your unique URL to connect to the Frontegg gateway
115
- FRONTEGG_BASE_URL='https://{YOUR_SUB_DOMAIN}.frontegg.com'
116
-
117
- # Your Frontegg application's Client ID
118
- FRONTEGG_CLIENT_ID='{YOUR_APPLICATION_CLIENT_ID}'
119
-
120
- # The statless session encruption password, used to encrypt
121
- # jwt before sending it to the client side.
122
- #
123
- # For quick password generation use the following command:
124
- # node -e "console.log(crypto.randomBytes(32).toString('hex'))"
125
- FRONTEGG_ENCRYPTION_PASSWORD='{SESSION_ENCRYPTION_PASSWORD}'
126
-
127
- # The statless session cookie name
128
- FRONTEGG_COOKIE_NAME='fe_session'
129
- ```
130
-
131
- ## Documentation
132
-
133
- ### API Reference
134
-
135
- Visit [Frontegg Docs](https://docs.frontegg.com) for the full documentation.
136
-
137
- ### Frontegg Provider Options
138
-
139
- Pass seconds argument to `withFronteggApp` function in `_app.ts` file to customize
140
- Frontegg library.
141
-
142
- ```tsx
143
- // ./pages/_app.tsx
144
-
145
- import { withFronteggApp } from '@frontegg/nextjs';
146
-
147
- function CustomApp({ Component, pageProps }: AppProps) {
148
- return <Component {...pageProps} />;
149
- }
150
-
151
- export default withFronteggApp(CustomApp, {
152
- /**
153
- * Frontegg options for customizations
154
- */
155
- });
156
- ```
157
-
158
- ### getSession
159
-
160
- For any pages that required AccessToken in Server Side, you can use:
161
-
162
- ```tsx
163
- import { GetServerSideProps } from 'next';
164
- import { getSession } from '@frontegg/nextjs';
165
-
166
- export default function MyPage({ products }) {
167
- return (
168
- <div>
169
- <h1>My Page</h1>
170
- {products}
171
- </div>
172
- );
173
- }
174
-
175
- export const getServerSideProps: GetServerSideProps = async (context) => {
176
- const session = await getSession(context.req);
177
- if (session) {
178
- const { data } = await fetch('{external}/product', {
179
- headers: {
180
- Authorization: 'bearer ' + session.accessToken,
181
- },
182
- });
183
- return { props: { products: data } };
184
- }
185
-
186
- return { props: { products: [] } };
187
- };
188
- ```
189
-
190
- ### withSSRSession
191
-
192
- withSSRSession HOC can be used to automatic redirect users to login screen if not logged in:
193
-
194
- ```tsx
195
- import { GetServerSideProps } from 'next';
196
- import { withSSRSession } from '@frontegg/nextjs';
197
-
198
- export default function MyPage({ products }) {
199
- return (
200
- <div>
201
- <h1>My Page</h1>
202
- {products}
203
- </div>
204
- );
205
- }
206
-
207
- export const getServerSideProps: GetServerSideProps = withSSRSession(
208
- async (context, session) => {
209
- const { data } = await fetch('{external}/product', {
210
- headers: {
211
- Authorization: 'bearer ' + session.accessToken,
212
- },
213
- });
214
- return { props: { products: data } };
215
- }
216
- );
217
- ```
7
+ Run `nx test nextjs` to execute the unit tests via [Jest](https://jestjs.io).
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@frontegg/nextjs",
3
- "version": "5.7.1-alpha.2726809355",
3
+ "version": "5.8.0",
4
4
  "dependencies": {
5
- "@frontegg/admin-portal": "5.66.1",
6
- "@frontegg/react-hooks": "5.66.1",
5
+ "@frontegg/admin-portal": "5.70.1",
6
+ "@frontegg/react-hooks": "5.70.1",
7
7
  "jose": "^4.8.0",
8
8
  "iron-session": "^6.1.2",
9
9
  "http-proxy": "^1.18.1",
@@ -16,4 +16,4 @@
16
16
  "main": "./index.cjs.js",
17
17
  "module": "./index.esm.js",
18
18
  "typings": "./index.d.ts"
19
- }
19
+ }