---
title: "Discussion on \"Next.js 13 Route Handlers with Typescript\" | Hashnode"
description: "Discussion on \"Next.js 13 Route Handlers with Typescript\". Learn how API routing works in Next.js 13 with GET, POST, PUT and DELETE requests."
url: "https://hashnode.com/posts/nextjs-13-route-handlers-with-typescript/648f2b23a3d4a7216732ba47"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Next.js 13 Route Handlers with Typescript](https://maryetokwudo.hashnode.dev/nextjs-13-route-handlers-with-typescript?utm_source=hashnode&utm_medium=feed)

Learn how API routing works in Next.js 13 with GET, POST, PUT and DELETE requests.

Jun 18, 2023 · 4 min read · maryetokwudo.hashnode.dev  
Read the article

-   [#womenwhotech](https://hashnode.com/tag/womenwhotech)
-   [#nextjs](https://hashnode.com/tag/nextjs)
-   [#nextjs-132](https://hashnode.com/tag/nextjs-132)
-   [#typescript](https://hashnode.com/tag/typescript)
-   [#frontend-development](https://hashnode.com/tag/frontend-development)

## Written by

[Mary Etokwudo](https://hashnode.com/@uniqcoda)

@uniqcoda · London, UK

  
[View profile](https://hashnode.com/@uniqcoda)

I am a fullstack developer with experience in NodeJS, React, GraphQL and every other thing in-between including HTML and CSS 😀

Experienced engineer with a strong background in data science, machine learning and web development. My current expertise revolves around Generative AI and multi-modal AI (Language &amp; Vision). I am passionate about writing clean, maintainable, and scalable code that facilitates easy collaboration. I am also heavy on AI Research.

## Responses 4

Markdown supported · ⌘↵ to post

[Grace Frank](https://hashnode.com/@gracey)

[Jul 3, 2023](https://hashnode.com/posts/nextjs-13-route-handlers-with-typescript/648f2b23a3d4a7216732ba47/comment/64a2c361fda312e2adb062c7)

What if I want to use env variables, will I define it differently from the frontend?

[Mary Etokwudo](https://hashnode.com/@uniqcoda)

[Jul 3, 2023](https://hashnode.com/posts/nextjs-13-route-handlers-with-typescript/648f2b23a3d4a7216732ba47/comment/64a2c361fda312e2adb062c7#reply-64a3235efc7c5ae54bc25275)

Hi Grace! When you add the prefix `NEXT_PUBLIC_` to your env variables, Next.js will make it available on the browser. For example:

NEXT\_PUBLIC\_GOOGLE\_ANALYTICS\_ID='your\_google\_analytics\_id'

Note that it is not advisable to expose sensitive variables to the browser. Let me know if this works or not :)

[Grace Frank](https://hashnode.com/@gracey)

[Jul 3, 2023](https://hashnode.com/posts/nextjs-13-route-handlers-with-typescript/648f2b23a3d4a7216732ba47/comment/64a28ea78db091c401036f70)

Also if I install a dependency, how will next.js know that the dependency is just for the frontend and not the backend?

[Mary Etokwudo](https://hashnode.com/@uniqcoda)

[Jul 3, 2023](https://hashnode.com/posts/nextjs-13-route-handlers-with-typescript/648f2b23a3d4a7216732ba47/comment/64a28ea78db091c401036f70#reply-64a3275f0d9d87e57bd724c8)

I think that by default, Next.js will try to make all the dependencies available on the frontend except those that need to run on a node environment. Check this [Q&A on server-side dependencies](https://trueq.io/q/2) as well.

[Grace Frank](https://hashnode.com/@gracey)

[Jul 3, 2023](https://hashnode.com/posts/nextjs-13-route-handlers-with-typescript/648f2b23a3d4a7216732ba47/comment/64a28b278db091c401036ea1)

What if I want to install dependencies and use them in side the route handler?

[Mary Etokwudo](https://hashnode.com/@uniqcoda)

[Jul 3, 2023](https://hashnode.com/posts/nextjs-13-route-handlers-with-typescript/648f2b23a3d4a7216732ba47/comment/64a28b278db091c401036ea1#reply-64a32643fc7c5ae54bc252b5)

You can do that the way we used `next/server` in the first code snippet.

[Higenyi Morris](https://hashnode.com/@Buya)

[Jun 20, 2023](https://hashnode.com/posts/nextjs-13-route-handlers-with-typescript/648f2b23a3d4a7216732ba47/comment/649190e3aa3e031681682f3c)

Thank you so much 💯. Exactly what I was looking for

[Mary Etokwudo](https://hashnode.com/@uniqcoda)

[Jun 25, 2023](https://hashnode.com/posts/nextjs-13-route-handlers-with-typescript/648f2b23a3d4a7216732ba47/comment/649190e3aa3e031681682f3c#reply-64981cdeee8fae5a272d9ff0)

You are welcome, Higenyi. Thanks for the comment.
