question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default export from next-routes

See original GitHub issue

Hi !

I’m trying to get next-routes working with TypeScript.

I have this code right now :

import Routes from 'next-routes';

const routes = new Routes();

routes
  .add('about')
  .add('post', '/p/:id')

export default routes;

But when I’m trying to compile I get this error :

const routes = new Routes(); ^ TypeError: next_routes_1.default is not a constructor

I followed example here

Could you please help me ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

6reactions
prevostccommented, May 24, 2018

Same here. I “solved” it with:

import * as createRoutes from "next-routes"
import Routes from "next-routes"

// @ts-ignore Types are broken
const routes: Routes = createRoutes()

routes
  .add("about")

export default routes
export const Link = routes.Link
export const Router = routes.Router
2reactions
smkhalsacommented, Jul 9, 2018

@fridays I believe there’s a pending PR to fix this. Can we get it merged please?

Read more comments on GitHub >

github_iconTop Results From Across the Web

next-routes - npm
Start using next-routes in your project by running `npm i next-routes`. ... export default class Blog extends React.
Read more >
Dynamic routing with next export mode - Stack Overflow
Js; Alternative library (I've looked at next-routes but that hasn't ... return { props: {}, }; } export default function FooPage(): JSX.
Read more >
Next-routes NPM - npm.io
export default class Blog extends React.Component { static async getInitialProps ({query}) { // query.slug } render () { // this.props.url.query.slug } } ...
Read more >
next-routes/README.md - UNPKG
48, ```javascript ; 49, export default class Blog extends React.Component { ; 50, static async getInitialProps ({query}) { ; 51, // query.slug ;...
Read more >
Advanced Features: Static HTML Export - Next.js
Features that require a Node.js server, or dynamic logic that cannot be computed during the build process, are not supported: Image Optimization (default...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found