Skip to content

Commit

Permalink
feat: add Next.js CSR example (#47)
Browse files Browse the repository at this point in the history
* feat: add nextjs csr example

* fix: update .eslintrc to ignore examples

* feat: update with sub check and update README

* fix: remove .DS_Store file

* fix: update build script and improve readability

* fix: change npm script to run sequentially instead of concurrently

* feat: improve store to be global, change README to start dev instead of start

* feat: update store type declaration
  • Loading branch information
raynerljm authored May 23, 2023
1 parent 1114f05 commit 25b8bab
Show file tree
Hide file tree
Showing 26 changed files with 7,832 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"parserOptions": {
"ecmaVersion": 2018
},
"ignorePatterns": ["examples/**/*"],
"overrides": [
{
"files": ["*.ts"],
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ dist
.tern-port

dist/

.DS_Store
3 changes: 3 additions & 0 deletions examples/nextjs-csr/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SGID_CLIENT_ID=
SGID_CLIENT_SECRET=
SGID_PRIVATE_KEY=
21 changes: 21 additions & 0 deletions examples/nextjs-csr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# sgID Next.js (CSR) Example

This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Getting Started

Before you can run the development server, you will have to register your client on the sgID [developer portal](https://developer.id.gov.sg/).

- For this example, you will need to include the following scopes `[openid, myinfo.name]` and register the following redirect URL `http://localhost:3000/api/callback`

> For more information about sgID, please visit the [developer documentation](https://docs.id.gov.sg/).
Copy the `.env.example` file, rename it to `.env`, and fill in your credentials obtained during registration.

Then, run the development server by running:

```bash
npm run dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
5 changes: 5 additions & 0 deletions examples/nextjs-csr/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
6 changes: 6 additions & 0 deletions examples/nextjs-csr/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}

module.exports = nextConfig
Loading

0 comments on commit 25b8bab

Please sign in to comment.