Skip to content

Commit

Permalink
Add app router example (#52066)
Browse files Browse the repository at this point in the history
- Add app router example to 03-environment-variables.mdx

Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
  • Loading branch information
3 people committed Jul 6, 2023
1 parent 202dcb0 commit 38e45f2
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,20 @@ export async function getStaticProps() {

<AppOnly>

This loads `process.env.DB_HOST`, `process.env.DB_USER`, and `process.env.DB_PASS` into the Node.js environment automatically allowing you to use them in Route Handlers.
This loads `process.env.DB_HOST`, `process.env.DB_USER`, and `process.env.DB_PASS` into the Node.js environment automatically allowing you to use them in [Route Handlers](/docs/app/building-your-application/routing/router-handlers).

{/* TODO: App Router Example */}
For example:

```js filename="app/api/route.js"
export async function GET() {
const db = await myDB.connect({
host: process.env.DB_HOST,
username: process.env.DB_USER,
password: process.env.DB_PASS,
})
// ...
}
```

</AppOnly>

Expand Down

0 comments on commit 38e45f2

Please sign in to comment.